JAVA中的多线程——死锁
JAVA中的多线程——死锁 了解死锁,是为了开发中避免死锁。 /* *死锁 *同步中嵌套同步,锁却不同 * **/ classTicket3implementsRunnable{ privateinttick=1000; Objectobject=newObject(); booleanflag=true; publicvoidrun(){ if(flag){ while(true){ synchronized(object){ show1(); } } } else{ while(true) show1(); } } publicsynchronizedvoidshow1(){ synchronized(object){ if(tick>0){ } try{ Thread.sleep(10); }catch(Exceptione){ //TODO:handleexception } System.out.println(Thread.currentThread().getName()+"sale:"+tick--); } } } publicclassDeadLockDemo{...

