Created
March 21, 2012 11:35
-
-
Save nschlimm/2146334 to your computer and use it in GitHub Desktop.
Closing with CompletionHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleChannelClose_CompletionHandler { | |
... | |
public static void main(String[] args) throws InterruptedException, IOException, ExecutionException { | |
... | |
outputfile.write(ByteBuffer.wrap("Hello".getBytes()), fileindex.getAndIncrement() * 5, "", defaultCompletionHandler); | |
... | |
} | |
private static CompletionHandler<Integer, String> defaultCompletionHandler = new CompletionHandler<Integer, String>() { | |
@Override | |
public void completed(Integer result, String attachment) { | |
// NOP | |
} | |
@Override | |
public void failed(Throwable exc, String attachment) { | |
System.out.println("Do something to avoid data loss ..."); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment