标签:style blog color io for ar art div
public class Main { public static void main(String[] args) { // TODO Auto-generated method stub MutiThread t=new MutiThread(); Thread t1=new Thread(t); /*多线程断点调试,错误结果,如果在此处执行断点,t1执行完毕,numa回复正确状态-------此处注意*/ t1.start(); for(int i=0;i<5;i++){ new Thread(t).start(); } t1.stop(); } } public class MutiThread implements Runnable { int numa=0; @Override public void run() { // TODO Auto-generated method stub synchronized (this) { numa++; try{ Thread.sleep(1000); }catch(Exception e){ e.printStackTrace(); } numa--; String stn=Thread.currentThread().getName(); System.out.println(stn+" numa= " + numa); } } }
关于多线程Thread.Stop()破坏原子性,布布扣,bubuko.com
标签:style blog color io for ar art div
原文地址:http://www.cnblogs.com/whut-lp/p/3926989.html