Hi all,
I am in process of writing a
java multithread program.
Following are the steps.
1. In a method I am creating 4 threads
public void
test()
{
DocThread t1 = new DocThread("one");
t1.start();
DocThread t2 = new DocThread("one");
t2.start();
DocThread t3 = new DocThread("one");
t3.start();
DocThread t4 = new DocThread("one");
t4.start();
Thread currentThread = Thread..currentThread();
try {
currentThread.sleep(10000);
}catch(Exception e) {
//do some thing
}
//do some work..
}
2. starting the above 4 threads.
3. using current thread to sleep let say 20000 in mani thread
but, what I am encountering is without waiting for all the above 4 threads the main thread exits after it sleeps for 20000?
Any one can give me better approch to wait for all the 4 threads finishes their jobs so the main thread will wait?
Thanks in Advance.
Kamal.