* Removed 'volatile' from the member variables that are protected by synchronized (this) block

* Updated comments regarding thread safety
This commit is contained in:
Trustin Lee 2010-02-19 08:23:48 +00:00
parent de8671df93
commit e8c320c6c3
2 changed files with 14 additions and 10 deletions

View File

@ -71,8 +71,8 @@ public class DefaultChannelFuture implements ChannelFuture {
private final Channel channel;
private final boolean cancellable;
private volatile ChannelFutureListener firstListener;
private volatile List<ChannelFutureListener> otherListeners;
private ChannelFutureListener firstListener;
private List<ChannelFutureListener> otherListeners;
private boolean done;
private Throwable cause;
private int waiters;
@ -345,9 +345,11 @@ public class DefaultChannelFuture implements ChannelFuture {
}
private void notifyListeners() {
// There won't be any visibility problem or concurrent modification
// because 'ready' flag will be checked against both addListener and
// removeListener calls.
// This method doesn't need synchronization because:
// 1) This method is always called after synchronized (this) block.
// Hence any listener list modification happens-before this method.
// 2) This method is only when 'done' is true. If 'done' is true,
// the listener list is never modified - see add/removeListener().
if (firstListener != null) {
notifyListener(firstListener);
firstListener = null;

View File

@ -48,8 +48,8 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
private final ChannelGroup group;
final Map<Integer, ChannelFuture> futures;
private volatile ChannelGroupFutureListener firstListener;
private volatile List<ChannelGroupFutureListener> otherListeners;
private ChannelGroupFutureListener firstListener;
private List<ChannelGroupFutureListener> otherListeners;
private boolean done;
int successCount;
int failureCount;
@ -346,9 +346,11 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
}
private void notifyListeners() {
// There won't be any visibility problem or concurrent modification
// because 'ready' flag will be checked against both addListener and
// removeListener calls.
// This method doesn't need synchronization because:
// 1) This method is always called after synchronized (this) block.
// Hence any listener list modification happens-before this method.
// 2) This method is only when 'done' is true. If 'done' is true,
// the listener list is never modified - see add/removeListener().
if (firstListener != null) {
notifyListener(firstListener);
firstListener = null;