⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mythread.java

📁 Threads为JAVA线程序例子集合.能方便了解JAVA线程的运作
💻 JAVA
字号:
public class MyThread extends Thread { 
int count= 1, number; 
public MyThread(int num) { 
number = num; 
System.out.println("创建线程 " + number); 
} 
public void run() {
 count();

}

public   synchronized void count(){
	try{
		int i=0;
			while(count<11) { 
			System.out.println("线程 " + number + ":计数 " + count); 
			i+=2;
			count+=i;
				if(i==2){
	 				this.notify();
				}else{
					this.wait();
				}
			}
		}
	catch(InterruptedException e){
		e.printStackTrace();
		}
 
	}
public static void main(String args[]) { 
for(int i = 0; i < 5; i++) new MyThread(i+1).start();
} 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -