class RunImp implements Runnable {
private int count = 0;
public void run() {
while (count < 5) {
synchronized (RunImp.class) {
if(count>=5)
break;
count++;
System.out.println(Thread.currentThread().getName() + "--------"
+ count);
}
}
}
}
public class ThreadTest2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
RunImp runImp = new RunImp();
new Thread(runImp).start();
new Thread(runImp).start();
}