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
Space pants. Tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
|