Java Code Examples for com.google.appengine.api.ThreadManager#createBackgroundThread()

The following examples show how to use com.google.appengine.api.ThreadManager#createBackgroundThread() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkerServlet.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Create App Engine threads that will poll and the process the tasks.
 */
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) {
  for (int workerNo = 0; workerNo < NUMBER_OF_WORKERS; workerNo++) {
    Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
      @Override
      public void run() {
        doPolling();
      }
    });
    thread.start();
  }
}
 
Example 2
Source File: NotificationCleanupServlet.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {

  Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
    @Override
    public void run() {
      doCleanup();
    }
  });

  thread.start();
}
 
Example 3
Source File: WorkerServlet.java    From solutions-mobile-backend-starter-java with Apache License 2.0 5 votes vote down vote up
/**
 * Create App Engine threads that will poll and the process the tasks.
 */
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) {
  for (int workerNo = 0; workerNo < NUMBER_OF_WORKERS; workerNo++) {
    Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
      @Override
      public void run() {
        doPolling();
      }
    });
    thread.start();
  }
}
 
Example 4
Source File: NotificationCleanupServlet.java    From solutions-mobile-backend-starter-java with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {

  Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
    @Override
    public void run() {
      doCleanup();
    }
  });

  thread.start();
}
 
Example 5
Source File: PushNotificationWorkerServlet.java    From solutions-ios-push-notification-sample-backend-java with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) {
  // Create App Engine threads that will poll and the process the tasks.
  for (int workerNo = 0; workerNo < NUMBER_OF_WORKERS; workerNo++) {
    Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
      @Override
      public void run() {
        doPolling();
      }
    });

    thread.start();
  }
}
 
Example 6
Source File: NotificationCleanupServlet.java    From solutions-ios-push-notification-sample-backend-java with Apache License 2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
  
  Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
    @Override
    public void run() {
      doCleanup();
    }
  });

  thread.start();
}
 
Example 7
Source File: InitializationServlet.java    From wt1 with Apache License 2.0 5 votes vote down vote up
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    System.out.println("*********************");
    Logger.getRootLogger().removeAllAppenders();
    BasicConfigurator.configure();

    registerShutdownHook();

    /* Load config */
    try {
        File configFile = new File(getServletContext().getRealPath(CONFIG_PATH));
        Properties props = new Properties();
        props.load(new FileReader(configFile));
        props.load(new FileReader(configFile));

        ProcessingQueue.getInstance().configure(props);

        /* Start all processing threads */
        for (Runnable runnable : ProcessingQueue.getInstance().getRunnables()) {
            Thread thread = ThreadManager.createBackgroundThread(runnable);
            thread.start();
        }

    } catch (Exception e) {
        throw new IOException("Could not create processing threads", e);
    }
    logger.info("App started");
}