Multi Thread

P

Piyush

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
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Piyush said:
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.

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
 
R

Richard Reynolds

Piyush said:
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
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.
 
L

Lew

Piyush said:
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

Unifying the multipost . . .
 
B

Bjorn Borud

[Piyush <[email protected]>]
|
| 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top