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


Java ThreadManager类代码示例

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


ThreadManager类属于com.google.appengine.api包,在下文中一共展示了ThreadManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createClient

import com.google.appengine.api.ThreadManager; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Client createClient(String configServiceName)
    throws GeneralSecurityException, IOException {
  return new Client.Builder(configServiceName)
      .setStatsLogFrequency(statsLogFrequency())
      .setHttpTransport(UrlFetchTransport.getDefaultInstance())
      .setFactory(ThreadManager.backgroundThreadFactory())
      .build();
}
 
开发者ID:cloudendpoints,项目名称:endpoints-management-java,代码行数:13,代码来源:GoogleAppEngineControlFilter.java

示例4: LoadMultipleParallel

import com.google.appengine.api.ThreadManager; //导入依赖的package包/类
public LoadMultipleParallel(final Collection<String> _ids, final DAO<E> _dao, final PropertyMeta _propertyMeta) {
    super((_ids.size() / QUERY_PACK_SIZE) < 1 ? 1 : (_ids.size() / QUERY_PACK_SIZE), ThreadManager.currentRequestThreadFactory());

    ids = new ArrayList<>(_ids);
    result = new HashMap<>(_ids.size());
    dao = _dao;
    propertyMeta = _propertyMeta;
}
 
开发者ID:ZupCat,项目名称:simple-datastore,代码行数:9,代码来源:LoadMultipleParallel.java

示例5: 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

示例6: 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

示例7: 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

示例8: start

import com.google.appengine.api.ThreadManager; //导入依赖的package包/类
/**
 * Starts the websocket server, registers necessary information and then starts the bridge
 * thread.
 */
public void start() {
  if (chatSocketServer != null) {
    throw new IllegalStateException("We already have a chatSocketServer.");
  }
  chatSocketServer = new ChatSocketServer(DEFAULT_PORT);
  chatSocketServer.start();
  LOG.info("Server started on port: " + chatSocketServer.getPort());
  try {
    registerWebSocketServerNode();
  } catch (IOException e) {
    LOG.warning(Throwables.getStackTraceAsString(e));
  }
  ThreadManager.createBackgroundThread(this).start();
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-websocketchat-java,代码行数:19,代码来源:ChatSocketServer.java

示例9: 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

示例10: execute

import com.google.appengine.api.ThreadManager; //导入依赖的package包/类
@Override
public void execute(Runnable command) {
    if(command != null){
        ThreadFactory threadFactory = ThreadManager.backgroundThreadFactory();
        ExecutorService service = Executors.newCachedThreadPool(threadFactory);
        service.execute(command);
        }
    }
 
开发者ID:dannormington,项目名称:appengine-cqrs,代码行数:9,代码来源:ThreadExecutor.java

示例11: 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

示例12: applyAppEngineKludge

import com.google.appengine.api.ThreadManager; //导入依赖的package包/类
/**
 * Overrides the threadFactory used in JSch and disable {@link Thread#setName(String)} in order to
 * ensure GAE compatibility. By default it uses the default executor, which fails under GAE. This
 * is currently a Google-specific patch that needs to be sent upstream.
 */
private static void applyAppEngineKludge() {
  JSch.threadFactory = ThreadManager.currentRequestThreadFactory();
  JSch.useThreadNames = false;
}
 
开发者ID:google,项目名称:nomulus,代码行数:10,代码来源:JSchModule.java


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