N
neuneudr
Hi,
if you want every method of a class to be synchronized, you
can use the @ThreadSafe annotation from JCIP and then use
FindBugs to find violations (at least that's the theory
However I'm wondering, when you have callbacks, those callbacks
are basically alien method calls and hence you cannot synchronize
every method?
So the following is incorrect because there's an alien method call:
public void synchronized doSomeStuff() {
...
if ( statechanged ) {
notifyObservers(); // alien method call
}
}
I have to write:
public void doSomeStuff() {
synchronized(this) {
...
}
if ( statechanged ) {
notifyObservers();
}
}
And then it means as soon as I've got callback I cannot
use the @ThreadSafe annotations from JCIP?
if you want every method of a class to be synchronized, you
can use the @ThreadSafe annotation from JCIP and then use
FindBugs to find violations (at least that's the theory
However I'm wondering, when you have callbacks, those callbacks
are basically alien method calls and hence you cannot synchronize
every method?
So the following is incorrect because there's an alien method call:
public void synchronized doSomeStuff() {
...
if ( statechanged ) {
notifyObservers(); // alien method call
}
}
I have to write:
public void doSomeStuff() {
synchronized(this) {
...
}
if ( statechanged ) {
notifyObservers();
}
}
And then it means as soon as I've got callback I cannot
use the @ThreadSafe annotations from JCIP?