Quote:
|
It's possible you might be trying to re-invent something that already works pretty well!
|
Funny thing is that that is exactly what I'm trying to do.
Quote:
|
A hack fix would be to add a thread.join(???) at the end of your for loop (after thread.start(), where ??? is just long enough to start your Command.
|
I feel like that is not a sufficiently consistent way of doing what I am trying to do. (As well as almost eliminating the purposes of doing it - that will either not wait long enough or make the commands run in sequence (and not concurrently))
My biggest issue is that when I tried to do this :
Code:
private void runConcurrentCommands(final Vector<CommandBase> v) {
currentCommand = 0;
Thread thread = null;
System.out.println("Current = "+currentCommand);
thread = new Thread(new Runnable() {
@Override
public void run() {
System.out.println("Running = "+currentCommand);
CommandBase.getInstance().run(v.get(currentCommand));
currentCommand++;
}
});
thread.start();
}
it did not change the output.
To me, that would eliminate the problem by only incrementing the commandCount AFTER the command has run (And not incrementing it beforehand on the first run).