Reputation: 640
I am developing a library which sends an asynchronous request to a server (in another thread).
Our clients will use this library, and I am thinking of the best way how to get this handled by them. The response might follow in seconds to a minute. I am doing this using the jersey-client and there already exists a listener which will be called in the other "async" thread.
So I have a shared ressource which will be "filled" with the response by the listener, but the main-thread has to call it to retrieve the response.
Is there a better way how the client might access or be "notified" that the response has arrived? Something like an EventNotifier? (If i implement something like this, shouldn't there exist something like polling on the notifier, but this means that there might exist another thread, which has to do this).
I have no influence on the client who is using my library, I can only make their life easier with an appropriate design of the library-functions they call.
Upvotes: 0
Views: 258
Reputation: 5654
What is the servlet container version you are trying to use ? Servlet 3.0 has builtin support for it
Upvotes: 2