Problem in Thread wakeup of Java NIO Client
I am writing a client using the Java NIO API. Before sending the messages through the channel to the server, I am writing the data to a variable and calling the wakeup method of the Selector, to wake up any thread waiting on the select method. However the problem here is the wakeup method is being called before the thread waits on the select. So, the wakeup call is wasted and the thread is waiting for the wakeup call after some time, which is causing an almost deadlock. Can you please tell me how to ensure that the wakeup call doesn't go waste.
Anil Kumar S. R.