当前位置: 首页>>代码示例>>Java>>正文


Java ThreadManager.createBackgroundThread方法代码示例

本文整理汇总了Java中com.google.appengine.api.ThreadManager.createBackgroundThread方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadManager.createBackgroundThread方法的具体用法?Java ThreadManager.createBackgroundThread怎么用?Java ThreadManager.createBackgroundThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.ThreadManager的用法示例。


在下文中一共展示了ThreadManager.createBackgroundThread方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import com.google.appengine.api.ThreadManager; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res)
		throws IOException {
	
	cl = getClass().getClassLoader();

	Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
		@Override
		public void run() {
			Thread.currentThread().setContextClassLoader(cl);

			doCleanup();
		}
	});

	thread.start();
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:18,代码来源:NotificationCleanupServlet.java

示例2: doGet

import com.google.appengine.api.ThreadManager; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
  
  Thread thread = ThreadManager.createBackgroundThread(new Runnable() {
    @Override
    public void run() {
      doCleanup();
    }
  });

  thread.start();
}
 
开发者ID:GoogleCloudPlatform,项目名称:solutions-ios-push-notification-sample-backend-java,代码行数:13,代码来源:NotificationCleanupServlet.java

示例3: doGet

import com.google.appengine.api.ThreadManager; //导入方法依赖的package包/类
/**
 * 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();
  }
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:16,代码来源:WorkerServlet.java

示例4: doGet

import com.google.appengine.api.ThreadManager; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {

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

  thread.start();
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:13,代码来源:NotificationCleanupServlet.java

示例5: doGet

import com.google.appengine.api.ThreadManager; //导入方法依赖的package包/类
@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();
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:solutions-ios-push-notification-sample-backend-java,代码行数:15,代码来源:PushNotificationWorkerServlet.java

示例6: doGet

import com.google.appengine.api.ThreadManager; //导入方法依赖的package包/类
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");
}
 
开发者ID:dataiku,项目名称:wt1,代码行数:28,代码来源:InitializationServlet.java

示例7: doGet

import com.google.appengine.api.ThreadManager; //导入方法依赖的package包/类
/**
	 * Call made from module when notification was added to task queue
	 */
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
//		super.doPost(req, resp);

		if(counter == null){
			counter = new SyncCounter();
		}
		

		/*
		 * Run a synced counter to work on polling in managed threads to deliver notifications as promptly as possible 
		 */
		for (int workerNo = counter.value(); workerNo < MAX_WORKER_COUNT; workerNo++) {

			// Get the current queue to check it's statistics
			Queue notificationQueue = QueueFactory
					.getQueue("notification-delivery");
			if (notificationQueue.fetchStatistics().getNumTasks() > 30 * counter.value()) {
				
				counter.increment();
				
				cl = getClass().getClassLoader();
				
				Thread thread = ThreadManager
						.createBackgroundThread(new Runnable() {

							public void run() {
						        Thread.currentThread().setContextClassLoader(cl);
								
								try {
									doPolling();
								} catch (Exception e) {
									e.printStackTrace();
								}
							}

						});
				thread.start();

			} else {
				break; // Current number of threads is sufficient.
			}
		}

		resp.setStatus(HttpServletResponse.SC_OK);

	}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:52,代码来源:NotificationWorkerServlet.java


注:本文中的com.google.appengine.api.ThreadManager.createBackgroundThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。