Not so fast, it is not that easy to implement good long polling.
The method you mentioned works well, but there is a serious issue of "thread starvation"
Each Long polling will use up one thread, if you have 1000 concurrent user you would need 1000 thread to service the long polling request ( which most of the time does update of the server side status on the client browser)
Jetty 6 has a continue pattern whcih cleverly releases the thread of long polling request to be used by rhe real application logic.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…