How to wait in main method until all thread are finished
Md Uddin
Greenhorn
Joined: Jan 11, 2006
Posts: 28
posted
0
I am very new with thread. Here is my problem.
I have one JSP where myApp.main method called (something like below):
Separate threads creates from after we call test.start(); .Right now the main method return where it was called from (my JSP), before all the thread finished (created from test.start()) That means it calls test.start() and return (doesn't wait all the threads to finish).
What I need to do to wait after test.start() method without returning from the main method till all the thread finish. So that when my JSP execute the line anotherObject.doSomething(); all the threads are finished.
Scenario: --------------------------------------------------------------- myApp.main() myApp.start() ABC.readData() JaxbReader.addDataEventListener(ABC) JaxbReader.startRead() Creates new JaxbReader.ThreadReader (extends Thread) JaxbReader.ThreadReader.start() -> Runs JaxbReader.ThreadReader in a thread << myApp.main() thread ends >>
<< Separate Thread >> JaxbReader.run() ... It creates More threads
<< Separate Thread >> ... ... ---------------------------------------------------------------------
Thank you in advance. [ November 07, 2008: Message edited by: Md Uddin ]
MURAD (SCJP 5.0, SCWCD 1.4)
If you learn to program in Java, you'll never be without a job! (Patricia Seybold in 1998) - Knowing the syntax of Java does not make someone a software engineer. (John Knight)