-
Notifications
You must be signed in to change notification settings - Fork 176
Description
Hi, I have just recently started using the json-data-generator, and it is a useful tool.
I noticed that the main thread never terminates, even after the simulation is finished. I might be missing something. I am wondering if this is on purpose or is it a bug?
From looking at the code, it seems that the main thread of the application is left waiting at line 162 of JsonDataGenerator forever (master branch), because the status of the "running" boolean within SimulationRunner, which is accessed using isRunning() is never updated once the simulation is finished.
The following is the while loop which seems to always last forever:
while (gen.isRunning()) {
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
//wakie wakie!
}
}
There are "running" booleans in three classes: JsonDataGenerator, SimulationRunner and EventGenerator. It looks like the problem is in the SimulationRunner. It creates a group of threads, and starts them running. But when you call the isRunning() method on it, it should be checking the running status of all the threads that it started. If it did that, its isRunning() method would return false when all the threads had ended, and so the JsonDataGenerator would also know when the simulation had ended, and the main thread would not wait at line 162 forever.
Within EventGenerator, the running boolean in there is set to false when a particular workflow is finished. But at the level of SimulationRunner, it seems to never update its boolean.
The consequence of this is that when a user runs the jar from the command line they have to do a CTRL+C to kill it.
Please let me know if I am missing something. Thanks