i'm confuse again
class ThreadTestMain {
public static void main(
String[] args) {
ObjectValue objectValue = new ObjectValue();
ThreadTest1 test1 = new ThreadTest1(objectValue);
ThreadTest2 test2 = new ThreadTest2(objectValue);
test1.start();
test2.start();
}
}
class ThreadTest1 extends
Thread {
private ObjectValue v;
public ThreadTest1(ObjectValue a) {
this.v = a;
}
public synchronized void run() {
while (true) {
try {
v.wait();
System.out.println("v.wait()");
} catch (Exception e) {}
}
}
};
class ThreadTest2 extends Thread {
private ObjectValue v;
public ThreadTest2(ObjectValue a) {
this.v = a;
}
public void run() {
while (true) {
try {
System.out.println(v.getABC());
} catch (Exception e) {}
}
}
}
class ObjectValue {
private String abc = "ABC";
public String getABC() {
return abc;
}
}
at v.wait(); is mean v is block, it can't access by another thread, this is true??
is there so many thread in exam right??
i don't understand this, wait(), notify(), notifyAll();
pls help me for SCJP...thank
Weerawit<br />SCJP 1.4, SCWCD 1.2, SCWCD 1.4, SCBCD 1.3, SCBCD 5.0, SCMAD 1.0, SCJA 1.0, SCDJWS, SCJD, SCEA, SCDJWS 1.5