From: Robert Klemme Date: 2004-11-01T02:18:56+09:00 Subject: Re: Thread::list and GC "Eric Hodel" schrieb im Newsbeitrag news:20041030190559.GB93473@segment7.net... > > But: this solution has a problem. You can't ensure that it terminates. > > You will have to set some kind of flag somewhere that no new threads are > > created anyway. *If* you do that, you can just as easily wait once for > > all > > currently running threads *after* the flag has been set because you know > > there will be no new threads. > > That flag is Thread.critical = true > > It will prevent the scheduling of other threads. Note that starting a > new thread can switch to that thread, so be careful. That's the wrong flag. This just prevents scheduling of threads on the thread scheduler level. But what you really want in this scenario is a flag that tells the part of the application that creates new threads again and again to not do this any more. If you use Thread.critical for this you could end up joining a thread that will not be scheduled and all the work that has to be done (i.e. all threads that are running and need to be terminated) will not be done; worse than that the process might freeze and not terminate. Note: it *might* work, but IMHO it's the wrong hammer. :-) Kind regards robert