//我期望的结果是:
//分别加减到多少随便线程自己。
//线程1:0 1 2 3 4 5
//线程2:4 3 2 1 0 -1 -2
//线程1:-1 0 1 2 3 ...
//...
public class ThreadPlusAndMinus { private int count;
 private int isRun;
 
 public static void main(String[] args) {  ThreadPlusAndMinus tpm = new ThreadPlusAndMinus();
  
  Thread t1 = new Thread(tpm.new MyThread(true));
//  Thread t2 = new Thread(tpm.new MyThread(true));
//  Thread t3 = new Thread(tpm.new MyThread(false));
  Thread t4 = new Thread(tpm.new MyThread(false));
  t1.start();
//  t2.start();
//  t3.start();
  t4.start();
 } private class MyThread implements Runnable {  private boolean isPlus;  public MyThread(boolean isPlus) {
   this.isPlus = isPlus;
  }  @Override
  public synchronized void run() {
   while (isRun++ < 100) {
    if (isPlus)
     count++;
    else
     count--;
    
    System.out.println(Thread.currentThread().getName() + ":" + count);
   }
  }
 }