Long Polling Implementation
<p>I have implement a long poll implementation. What happening is, when the request comes I check whether some data is available and if not sleep the thread and recursively call the method till data is available.</p>

<pre><code>int time = 0;
String data;

public void checkme() {    
    time++;
    if (data == null &amp;&amp; time &lt; 100) {
        System.out.println("recursive call "+time);
        try {
           Thread.sleep(5000);
        } catch (InterruptedException e) {
           e.printStackTrace();
        }
        checkme();
        } else {
           System.out.println("end recursive call. data available");
        }
}
</code></pre>

<p>But even when I cancel the request in postman, still the recursive call is happening in background.</p>

<p>So I think my long poll implementation is wrong and which I may need to track the request also from service later or use Queue like data structure.</p>