Hi all,
I have a multi-threaded program. This program, lets say spawns 10 threads. I would like to update a variable when each thread finishes its job.
The reason why I am asking this, is because I would like to show something like progress bar (not really a progress bar, but display a precentage of job completion, while the program is running).
I have this thaugh, and someone please correct me if I am wrong.
I have the following classes
- MainProgram.java
- MainProgramThread.java
- MainProgramProgressThread.java
If MainProgram creates 10 instance of MainProgramThread class, I would like to decrement a counter (which has the maximum number of threads running)
On the other hand, MainProgramProgressThread class will only display the progress percentage (this will be calculated) so long as the number of counter is greater than zero when this value reaches 0, then I would like the ProgressThread to stop.
So, my question is how can I know when a thread ends?
Or if there's another way of doing what I would like to do, I am open to ideas.
Thanks in advance...