首页 > 代码库 > 多线程复习

多线程复习

OS看到进程管理这一章,对进程、线程的理解又加深了一层,考研这段时间好久没写代码,复习一下线程,一个小demo:

package threadone;public class ThreadTest {	 public static void main(String[] args) {		 HelloRunner r1=new HelloRunner("r1  ");		 HelloRunner r2=new HelloRunner("r2  ");		 HelloRunner r3=new HelloRunner("r3  ");		 r1.start();		 r2.start();		 r3.start();				 	}}class HelloRunner extends Thread{		private String name;		public HelloRunner(String name) {		super();		this.name = name;	}	public void run(){		int i=0;		while(true){			System.out.println(name+i++);						if(i==10){ break;}		}	}		} 

  

多线程复习