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);
}
}