From: Eric Hodel Date: 2004-11-01T15:48:42+09:00 Subject: Re: Thread::list and GC --1XWsVB21DFCvn2e8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Robert Klemme (bob.news@gmx.net) wrote: >=20 > "Eric Hodel" schrieb im Newsbeitrag=20 > 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 a= re > >> created anyway. *If* you do that, you can just as easily wait once fo= r=20 > >> all > >> currently running threads *after* the flag has been set because you kn= ow > >> there will be no new threads. > > > >That flag is Thread.critical =3D true > > > >It will prevent the scheduling of other threads. Note that starting a > >new thread can switch to that thread, so be careful. >=20 > That's the wrong flag. This just prevents scheduling of threads on the= =20 > thread scheduler level. But what you really want in this scenario is a= =20 > flag that tells the part of the application that creates new threads agai= n=20 > and again to not do this any more. If you use Thread.critical for this y= ou=20 > could end up joining a thread that will not be scheduled and all the work= =20 > that has to be done (i.e. all threads that are running and need to be=20 > terminated) will not be done; worse than that the process might freeze an= d=20 > not terminate. >=20 > 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... --=20 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= =s+ml -----END PGP SIGNATURE----- --1XWsVB21DFCvn2e8--