本文整理汇总了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();
}
示例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();
}
}
示例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();
}
示例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");
}
示例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);
}