a fun coding question# Java - 爪哇娇娃
c*n
1 楼
what's wrong with following code?
just try it ...
public class block {
Integer a = new Integer(0);
void dead() throws Exception {
synchronized ( a ) {
while ( a == 0 )
a.wait();
}
}
public void release() {
synchronized(a) {
a = 1;
a.notifyAll();
}
}
public void demo() throws Exception {
new Thread() {
public void run() { try { dead() ; } catch (Exception e )
{System.out.pri
just try it ...
public class block {
Integer a = new Integer(0);
void dead() throws Exception {
synchronized ( a ) {
while ( a == 0 )
a.wait();
}
}
public void release() {
synchronized(a) {
a = 1;
a.notifyAll();
}
}
public void demo() throws Exception {
new Thread() {
public void run() { try { dead() ; } catch (Exception e )
{System.out.pri