I’m trying to run a NIO Server in it’s own Thread.
In my run function I defined:
while(running)
{
System.out.println("Server running!");
try
{
this.selector.select();
}
catch (IOException e)
{
e.printStackTrace();
}
}
The run loops only runs one time and then it’s stuck.
Without the whole try block it works.
It the selector.select() blocking somehow?
The documentation says,
So it should block until a channel is selected.
For non-blocking select/busy loop, try selectNow method.