Hello,
I am working on project, where the program creates multiple threads
which depends on other data stored in database. Threads can be n nos.
Also the process of all threads depends on other data (eg. Image
files). I have got one more process which depends on this threads. Now
the problem is how do I know that all the threads process is finished?
I am not so good with java. So if anyone can explain me in details.
Thanks
Gerhard Häring - 09 Jul 2007 16:45 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> the problem is how do I know that all the threads process is finished?
> I am not so good with java. So if anyone can explain me in details.
Some people, when confronted with a problem, think "I know, I'll use
threads." Now they have two problems.
... You'll have to join() all your threads.
-- Gerhard
Richard Reynolds - 09 Jul 2007 22:24 GMT
> Hello,
>
[quoted text clipped - 6 lines]
>
> Thanks
many ways to do this, a simple one is to use synchronised counter, increment
it each time you sart a new thread and have each new thread decrement it
when it's done and notify the main thread, the controlling thread "waits"
until the counter is 0 before it continues.
Have a look at the Thread.join method too and also some of the new
concurrency features in java 1.5/6.
Lew - 10 Jul 2007 00:57 GMT
> Hello,
>
[quoted text clipped - 6 lines]
>
> Thanks
Unifying the multipost . . .

Signature
Lew
Bjorn Borud - 10 Jul 2007 15:08 GMT
[Piyush <netandme@gmail.com>]
| I am working on project, where the program creates multiple threads
| which depends on other data stored in database. Threads can be n nos.
| Also the process of all threads depends on other data (eg. Image
| files). I have got one more process which depends on this threads. Now
| the problem is how do I know that all the threads process is finished?
| I am not so good with java. So if anyone can explain me in details.
actually, it would be better to understand what you were trying to
accomplish before giving any advice. what does your program do? why
do you have multiple threads? why do they have to wait for each other?
-Bjørn