when the main thread terminates all other threads have been terminated
all events occur in real time
when the main thread terminates all other threads have been terminated
SCJP 5.0
SCJP 5.0
Originally posted by Prahlad Joshi:
and i think we can replace
while (Thread.activeCount() > 1) {
Thread[] threads = new Thread[Thread.activeCount()];
Thread.enumerate(threads);
Thread th = null;
for (int i = 0; i < threads.length; i++) {
if (threads[0] != Thread.currentThread()) {
th = threads[0];
break;
}
}
if (th != null) {
boolean joined=false;
do {
try {
th.join();
joined = true;
} catch(InterruptedException i) {}
} while(!joined);
}
}
by while (Thread.activeCount() > 1);
SCJP 5.0
Everybody's invited. Except this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|