Reputation: 71
I have a simple app that connects to a server, sends an ACK, then sends a file to be processed. The server sends back an ACK then sends the results of processing the input file, which may happen a few seconds after sending the ACK. If I don't start a timer thread and keep checking whether the response file has come in after the ACK, my main thread exits. I would have expected the receiving socket to remain open until explicitly closed.
I would be grateful if someone could summarize the patterns that apply to using wait timers in Netty.
Upvotes: 0
Views: 382
Reputation: 12817
I would suggest using a java.util.concurrent.CountDownLatch. Initialize to 1 (one), and pass it to your channel handler, and wait for it to reach zero in the main thread. When the handler receives the final result it decrements the latch.
Upvotes: 1