What about having each thread point to an object containing an
integer. When each thread starts the integer is incremented (starting
at 0), and when each thread terminates the integer is decremented. If
the last thread finds that the integer is 0, then it calls
System.exit() with a return value that was previously set.
Ian.
> Unfortunately this seems harder said then done in java. If somebody knows
> a good way to do it I would be very interested.
>
> (Note: I am well aware of the System.exit(int) method, but the clients are
> multithreaded, so I don't want to finish "now" I want something like
> System.setExitStat(int) so that it returns that exit status when it exits
> normally because all the threads have ended. Otherise I'll have to do
> something like:
>
> Thread[] ts; int count;
> do {
> CurrentThread.yield();
> count = 0;
> ts = new Thread[Thread.activeCount()];
> int n = Thread.enumerate(ts);
> for (int i = 0; i < n ; i++) {
> if (!ts[i].isDaemon())
> count++;
> }
> } while (count > 1);
> System.getRuntime().exit(exitStatus);
>
> which is a little kludgy).
>
>
> > Mark Roberts
> > mroberts100 at mediaone.net
> >
> > _______________________________________________
> > Freenet-dev mailing list
> > Freenet-dev at lists.sourceforge.net
> > http://lists.sourceforge.net/mailman/listinfo/freenet-dev
> >
>
> --
> \oskar
>
> _______________________________________________
> Freenet-dev mailing list
> Freenet-dev at lists.sourceforge.net
> http://lists.sourceforge.net/mailman/listinfo/freenet-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20000821/fbde889a/attachment.pgp>