I have previous experience doing a long polling with PHP and jQuery that check for new chat messages.
The Idea was to have a while loop that checks if there are new messages, if yes, then returns the new message, if no then sleep for 5 seconds and check again.
I would like to do the same using java struts2 framework. I created an action class that has a while loop, does the same, and use Thread.sleep() for the wait.
However I experience some very high CPU usage. Am I doing it right? I apologize that I do not ave any sample code right now because I re-did it using a simple approach that uses client-side polling.
Help appreciated.