Thread problems

Hi:I have coded a class A which starts a new thread when it is called.Also I get a class B in which I call A for several times.My question is how do I in class B know the end of all threads which started by me? Is there some APIs that inform me?Thanks.
[287 byte] By [superspidera] at [2007-11-26 21:38:45]
# 1
> "know the end"?
DrLaszloJamfa at 2007-7-10 3:21:59 > top of Java-index,Java Essentials,Java Programming...
# 2
t1.start();t2.start();t1.join();t2.join();// When we get here, t1 and t2 are done.
jverda at 2007-7-10 3:21:59 > top of Java-index,Java Essentials,Java Programming...
# 3
I mean how do I know a thread is ended?
superspidera at 2007-7-10 3:21:59 > top of Java-index,Java Essentials,Java Programming...
# 4

> I mean how do I know a thread is ended?

By calling join.

That's the simplest way, if you only need to know when all threads are done. If you want to know as soon as each one is done, without having to worry about the order or waiting till they're all done, then when each thread finishes, it will have to call some method on some shared object that the main thread can observe.

jverda at 2007-7-10 3:21:59 > top of Java-index,Java Essentials,Java Programming...
# 5
Also, do you want to block until those threads are done, or do youwant to be asynchronously notified when the last thread is done?
DrLaszloJamfa at 2007-7-10 3:21:59 > top of Java-index,Java Essentials,Java Programming...
# 6
I just want class B to know the end of all the threads started in A.How? thanks
superspidera at 2007-7-10 3:21:59 > top of Java-index,Java Essentials,Java Programming...
# 7
> I just want class B to know the end of all the> threads started in A.> > How? thanksI already told you.Twice.
jverda at 2007-7-10 3:22:00 > top of Java-index,Java Essentials,Java Programming...
# 8
Thanks for the answering, I finish it.
superspidera at 2007-7-10 3:22:00 > top of Java-index,Java Essentials,Java Programming...