Java線程

今天是開學的第一天,開始上課我們講解了線程。
說實話這些知識已經講解過了。
可惜由於自己的不努力,早已忘得一乾二淨~~  類似的事情不能再發生!!

package Demo;

public class Demo{

public static void main(String args[]){
TestThread a=new TestThread();
new Thread(a).start();
new Thread(a).start();
new Thread(a).start();
new Thread(a).start();

}
}
class TestThread extends Thread{
public int tickets=100;
public void run(){
while(true){
if(tickets>0){
System.out.println("run():"+Thread.currentThread().getName()+"賣票"+tickets--);
}
}
}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章