歡迎訂閱杜仲教學頻道: https://www.youtube.com/channel/UCElwt6s8Ea_V-gnu9sZZT5g?sub_confirmation=1 杜仲教學部落格: https://derekcctu.blogspot.com/
訂閱:
張貼留言 (Atom)
Ether.fi Cash Card 一張所有人必備的加密貨幣信用卡 [Ether.fi Cash Card] : https://www.ether.fi/app/cash/sign-up?ref_code=d27f8523 ------國際交易所------ [Bitg...
-
22.Hamster Kombat Daily Combo倉鼠戰鬥_DailyCombo0620 ------國際交易所------ [Bitget 交易所]: https://partner.bitget.com/bg/DCA888 邀請碼:DCA888 [Bybit交...
-
[CATS coin每日任務(Ton區塊鏈游戲伏擊百倍幣)] https://t.me/catsgang_bot/join?startapp=FXvTt0OIdo7NJ4jxDutEV ------國際交易所------ [Bitget 交易所]: https://partn...
class Test implements Runnable{
回覆刪除String id;
Test(String name){
id=name;
}
@Override
public void run() {
for(int i=1;i<=4;i++){
int timer=(int)(Math.random()*1000);
try {
Thread.sleep(timer);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread t=Thread.currentThread();
System.out.println(id+" is running..timer="+timer+"當前執行緒:"+t.getName());
}
}
}
public class A14 {
public static void main(String[] args) {
Test dog=new Test("dog");
Test cat=new Test("cat");
Thread t1=new Thread(dog,"1.狗執行緒");
Thread t2=new Thread(cat,"2.貓執行緒");
t1.start();
try {
t1.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
t2.start();
try {
t2.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int a=155,b=9;
System.out.println(a+"/"+b+"="+a/b);
System.out.println("主程式結束...");
}
}
/*
class Test extends Thread{
String id;
Test(String name){
id=name;
}
public void run(){
for(int i=1;i<=4;i++){
for(int j=1;j<999999999;j++);
System.out.println(id+" is running..");
}
}
}
*/