diff --git a/transport/src/main/java/io/netty/channel/AbstractChannel.java b/transport/src/main/java/io/netty/channel/AbstractChannel.java index eb99cef373..3bdff15402 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannel.java @@ -359,6 +359,13 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha */ protected abstract class AbstractUnsafe implements Unsafe { + private final Runnable flushTask = new Runnable() { + @Override + public void run() { + flush0(); + } + }; + @Override public final SocketAddress localAddress() { return localAddress0(); @@ -609,12 +616,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha } else { if (!flushNowPending) { flushNowPending = true; - eventLoop().execute(new Runnable() { - @Override - public void run() { - flush0(); - } - }); + eventLoop().execute(flushTask); } } }