title: Multithreading with Appengine
body: <p>Since Appengine won't allow java multithreading, how then can we migrate our existing multithreaded code to the platform? </p>
  
  <p>For example I have the following code:</p>
  
  <pre><code>    Thread t = new Thread() {
          public boolean alive = true;
          public void run() {
              while (alive) {
                  try {
                      Thread.sleep(5000);    
                      getNewNotifications();
                  } catch (InterruptedException e) {
                      //  Do nothing
                  } catch (IOException e) {
                  } 
              }
          }
      };
      t.start()
  </code></pre>
  
  <p>The function getNewNotification() does some several Rest/HTTP calls, that may include some other process that may return indefinitely. I have read the <code>Task Queue</code> is the solution, however how do we convert this simple code into App engine-friendly code? </p>
  
  <p>How is the code above implemented using Task queue? For example to call <code>getNewNotifications()</code> for every five seconds.</p>
  
  <p>And that function will get some results from the server, parse the result and then execute the activities/work it needs to do based on the result. </p>