public
class
apples{
public
static
void
main(String[] args){
Thread
t1 = new
Thread(new
tuna("one"));
→ 創建Thread
Thread
t2 = new
Thread(new
tuna("two"));
Thread
t3 = new
Thread(new
tuna("three"));
Thread
t4 = new
Thread(new
tuna("four"));
t1.start();
→ 啟動Thread
t2.start();
t3.start();
t4.start();
}
}
這是運行時的結果:
two
as sleeping for 74
one
as sleeping for 345
four
as sleeping for 362
three
as sleeping for 420
two
is done
one
is done
four
is done
three
is done
沒有留言:
張貼留言