📄 machinerush.java
字号:
package synctatic;
public class MachineRush implements Runnable{
private static int a=1;
public void go(){ //this process is a
for(int i=0;i<1000;i++)
{
System.out.println(Thread.currentThread().getName()+":"+i);
Thread.yield();
}
}
public void run(){
for(int i=0;i<10;i++){
synchronized(this){ a+=i;
try{Thread.sleep(50);
}catch(InterruptedException e){throw new RuntimeException(e);}
}
}
}
public static void main(String args[])throws InterruptedException{
MachineRush machine=new MachineRush();
Thread t1=new Thread(machine);
Thread t2=new Thread(machine);
t1.start();
t2.start();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -