Is it possible for a child thread to be a parent i.e. to spawn another thread? Or is it that the main thread is the only thread that can spawn a child thread?
main-------child------child // is this possible? main |-------child // or is this the only way |-------child // to create a multiple |-------child // child threads
I have this program that tries to do this.
1. The method m1() is suppose to create the thread B - a child of thread A 2. The join() method is there for A to wait until B completes. But the result is not what I expect. B will complete but A will wait forever. So it seems that B is not a child of A. [ July 03, 2003: Message edited by: Alton Hernandez ]
I think the problem is that you are joining thread A to itself. You need for the thread A to have a reference to the thread B and from within thread A's code do a join on the reference of thread B. When you do this.join() you are telling the running thread to wait until he has finished before he continues. You can start a new thread from a child thread, it doesn't have to be from the main thread. [ July 03, 2003: Message edited by: Damien Howard ]