--1XWsVB21DFCvn2e8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Robert Klemme (bob.news / gmx.net) wrote: > > "Eric Hodel" <drbrain / segment7.net> 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. :-) I also forgot, setting Thread.critical to true, then joining another thread may not resume the first thread... -- Eric Hodel - drbrain / segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --1XWsVB21DFCvn2e8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQFBhdxHMypVHHlsnwQRAsdMAKCtpBxl1UJOQOusBt7ijTq5s6sBPQCZAaUg DVXNfJH0LF1d6O0tXWgtYEg ml -----END PGP SIGNATURE----- --1XWsVB21DFCvn2e8--