Really basic threading question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Really basic threading question

Threaded View

  1. #1
    Join Date
    May 2005
    Posts
    5

    Really basic threading question

    I've tried to understand threading from ten different tutorials, but it makes my head spin because all the tutorials include so much extra stuff that I don't know what's important.

    I've got a piece of code here with a gui, which contains a progress bar. I'd like the progress bar to update in a timely fashion, but not take up much of the main thread's recources.

    I've cut the code down to it's barest minimum. I'd really appreaciate it if someone were to tell me how to edit this code so that it implements threading? Thanks so much!

    Code:
    public class MeGA {
    	
    	private static Interface gui;
    	private static EvolutionEngine engine;
    
    	public static void main(String[] args) {
    		
    		engine = new EvolutionEngine();
    		gui = new Interface(engine);
    		engine.setGUI(gui);
    	}
    }
    
    public class Interface {
    
    	// A bunch of methods that set up the gui
    
    	...
    
    	// And then my progress bar method
    	
    	public void updateProgressBar(int value){
    		bar.setValue(value);
    	}
    }
    	
    
    public class EvolutionEngine {
    
    	public void start() {
    	
    		For (int i=0; i<x; i++)
    
    			// Do a bunch of stuff
    
    			// then update progress bar
    			gui.updateProgressBar(i);
    	}
    }
    Last edited by Asbestos; 06-09-2005 at 02:26 PM. Reason: wording

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center