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

📄 machine2.java

📁 这一些程序都是实验之用
💻 JAVA
字号:
package withdaemon;
public class Machine2 extends Thread{
	private int a;
	private static  int count;
	
	public void start()
	 {
	 	 super.start();
	 	 Thread deamon=new Thread()
	 	 					  {
	 	 	public void run()	{
	 	 	
	 	 	 while(true) 		  { 
	 	 	 reset();
	 	 	 try{
	 	 	 	 sleep(100);
	 	 	 	 
	 	 	 }catch(InterruptedException e){ throw new RuntimeException(e);}
	 	  						}
	 	  					}
	 	 				};
	 	  deamon.setDaemon(true);
	 	  deamon.start();
	 	  }
	 	  public void reset(){ a=0;}
	 	  	 public void run(){
	 	  	 	 while(true){
	 	  	 	 	 System.out.println(getName()+":"+a++);
	 	  	 	 	 if(count++==100)break;
	 	  	 	 	 yield();
	 	  	 	 	 
	 	  	 	 }
	 	  	 }
	 	  	 public static void main(String args[])throws Exception{
	 	  	 	 Machine2 machine=new Machine2();
	 	  	 	 machine.start();
	 	  	 }
	 	  }
	 

⌨️ 快捷键说明

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