阅读背景:

多线程(创建线程-实现Runnable接口)

来源:互联网 

class TWindow implements Runnable{
	private int tickNum = 100;
	public void run(){
		while(true){
			if(tickNum >0){
				System.out.println(Thread.currentThread().getName()" sale: "+ tickNum--);
			}
		}
	}
}

class Ticket{
	public static void main(String[] args){
		TWindow t = new TWindow();//这行代码未创立线程
		
		Thread t1 = new thread();//创立一个线程
		Thread t2 = new thread();//创立一个线程
		Thread t3 = new thread();//创立一个线程
		Thread t4 = new thread();//创立一个线程
		
		t1.start();
		t2.start();
		t3.start();
		t4.start();
	}
}class TWindow implements Runnable{
	private int ti




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: