V
VisionSet
I'm aware that nesting synchronisation blocks is generally a bad idea.
Is this just due to the ease of deadlock?
Does this advice apply to implicit inner locks eg
Set mySyncedSet = Collections.synchronizedSet(new HashSet());
....
synchronized(this) {
mySyncedSet.add(anObj);
}
I guess in this case it would be fine because the Set is not going to hold
any locks for long.
I suppose the only problem would be if the inner lock does a loop on wait()
or blocks on I/O.
But the Javadoc(umentation) is not enforced in this area, it is not always
apparant if a method is synced or not, let alone the details of the objects
blocking.
Any guidelines available in this case?
Is this just due to the ease of deadlock?
Does this advice apply to implicit inner locks eg
Set mySyncedSet = Collections.synchronizedSet(new HashSet());
....
synchronized(this) {
mySyncedSet.add(anObj);
}
I guess in this case it would be fine because the Set is not going to hold
any locks for long.
I suppose the only problem would be if the inner lock does a loop on wait()
or blocks on I/O.
But the Javadoc(umentation) is not enforced in this area, it is not always
apparant if a method is synced or not, let alone the details of the objects
blocking.
Any guidelines available in this case?