一,JAVA设计四个线程对象,两个线程执行加操作,两个线程执行减操作
package one;
import java.io.*;
public class one1 implements Runnable{
private static int count=0;
public void run()
{
while(true)
{
if(Thread.currentThread().getName().startsWith("add"))
count++;
else
count--;
System.out.print(count);
try{
Thread.sleep(500);
}catch(Exception e){
e.printStackTrace();
}
}
}
public static void main(String[] args) throws Exception {
one1 test=new one1()