join()
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
ThreadCase t = new ThreadCase();
t.start();
System.out.println("start...");
long before = System.currentTimeMillis();
t.join();
long after = System.currentTimeMillis();
System.out.println("total is: " + t.count + " cost: " + (after-before) + " ms");
}
static class ThreadCase extends Thread{
int count;
public void run() {
for(int i=0; i<10; i++) {
count += i;
}
System.out.println("caculate completely.");
}
}
wait(), notify
public static void main(String[] args) throws Interrupt