I want to make a service that basically holds a connection till a second connection is made to tell it to stop holding the first one.
Using NIO Http Connector with all default settings (in Tomcat and the connector).
I use a thread (much like the "messageSender" class in the tomcat aio doc) to hold the first response and write/flush a character every 5 seconds. This is working fine - the thread holds it and releases it on cue. The only problem is that the service ('event' method) does not get a second call (for the second connection's 'begin' event) till I close the first connection.
So to repeat, this is what happens:
connection 1 - > tomcat creates thread 'http-nio-8081-exec-2' which calls myService.event(event);
myService.event gives the response to 'myDaemonThread' (which holds the reference and writes to the response every 5 seconds). exits method.
'myDaemonThread' uses "synchronized (this){ this.wait(5000); }" for waiting (initially used Thread.sleep() but in an attempt to make this work, I changed to wait() )
connection 2 - > initiated but no thread calls myService.event
connection 1 is stopped in the browser, tomcat creates thread 'http-nio-8081-exec-4' which calls myService.event(event.END). exits method.
tomcat (creates ?? now or earlier, cant tell) thread 'http-nio-8081-exec-6' calls myService.event(event.BEGIN) for connection two.
...... the rest is unimportant.
So this seems to defeat the entire purpose of using NIO... anyone have any idea why this is happening?