Server/Client Notification over HTTP using Thread.wait
Posted on 2004-08-12
I am working on a Java server program that can notify a windows C++ client when a specific event occur (for example another user logs in).
The solution needs to work across firewalls and proxies so I have so far been using HTTP but due to the request/response nature of HTTP that gives me some problems.
So far I have been looking at a solution where the server does not respond to the clients HTTP request until the notification is ready to be sent, i.e. the server holds the thread (Thread.wait()) created by the clients request.
1) I am afraid that this solution can give me problems when many users logged are in, i.e. I have to hold maybe 2000 Threads. Does anyone know if this could be a problem?
2) Can anyone else suggest another technique that would achive what I want?
3) It seems to me that ASP.NET has something called IAsyncResult which allows a Thread to be given back to the process pool when the thread is blocked (sleeps). Does Java have something similar?
I would like to use a standard HTTP server like tomcat so that I can avoid having to implement my own HTTP server.