Simple java syncrhonization question
Posted
by Misha Koshelev
on Stack Overflow
See other posts from Stack Overflow
or by Misha Koshelev
Published on 2010-06-12T03:34:15Z
Indexed on
2010/06/12
3:42 UTC
Read the original article
Hit count: 323
java
|synchronized
Dear All:
Was wondering, which is correct:
Option One
class A {
public void methodOne() {
synchronized(this) {
modifyvalue
notifyAll()
}
}
public void methodTwo() {
while (valuenotmodified) {
synchronized(this) {
wait()
}
}
}
Option Two
class A {
public void methodOne() {
modifyvalue
synchronized(this) {
notifyAll()
}
}
public void methodTwo() {
while (valuenotmodified) {
synchronized(this) {
wait()
}
}
}
and why?
Thank you Misha
© Stack Overflow or respective owner