Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.appengine.api
Class ThreadManager

    java.lang.Object
      com.google.appengine.api.ThreadManager

    public final class ThreadManager

extends java.lang.Object

`ThreadManager` exposes a `ThreadFactory` that allows App Engine applications to spawn new threads.

Constructor Summary
`ThreadManager()`

Method Summary
`static java.util.concurrent.ThreadFactory` | `backgroundThreadFactory()` Returns a `ThreadFactory` that will create threads that are independent of the current request.
`static java.lang.Thread` | `createBackgroundThread(java.lang.Runnable runnable)` Create a new `Thread` that executes `runnable` independent of the current request.
`static java.lang.Thread` | `createThreadForCurrentRequest(java.lang.Runnable runnable)` Create a new `Thread` that executes `runnable` for the duration of the current request.
`static java.util.concurrent.ThreadFactory` | `currentRequestThreadFactory()` Returns a `ThreadFactory` that will create threads scoped to the current request.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ThreadManager

    public ThreadManager()

Method Detail

### currentRequestThreadFactory

    public static java.util.concurrent.ThreadFactory currentRequestThreadFactory()

  Returns a `ThreadFactory` that will create threads scoped to the current request. These threads will be interrupted at the end of the current request and must complete within the request deadline.

  Your code has limited access to the threads created by this `ThreadFactory`. For example, you can call `Thread.setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)` and `Thread.interrupt()`, but not `Thread.stop()` or any other methods that require `RuntimePermission("modifyThread")`.

  Note that calling `ThreadFactory.newThread(java.lang.Runnable)` on the returned instance may throw any of the unchecked exceptions mentioned by `createBackgroundThread(java.lang.Runnable)`.

### createThreadForCurrentRequest

    public static java.lang.Thread createThreadForCurrentRequest(java.lang.Runnable runnable)

  Create a new `Thread` that executes `runnable` for the duration of the current request. Calling this method is equivalent to invoking `ThreadFactory#run` on the ThreadFactory returned from `currentRequestThreadFactory()`. This thread will be interrupted at the end of the current request and must complete within the request deadline.

  Throws:
    `ApiProxy.FeatureNotAvailableException` - If this application cannot use this feature.

### backgroundThreadFactory

    public static java.util.concurrent.ThreadFactory backgroundThreadFactory()

  Returns a `ThreadFactory` that will create threads that are independent of the current request.

  This ThreadFactory can currently only be used by backends.

  Note that calling `ThreadFactory.newThread(java.lang.Runnable)` on the returned instance may throw any of the unchecked exceptions mentioned by `createBackgroundThread(java.lang.Runnable)`.

### createBackgroundThread

    public static java.lang.Thread createBackgroundThread(java.lang.Runnable runnable)

  Create a new `Thread` that executes `runnable` independent of the current request. Calling this method is equivalent to invoking `ThreadFactory#run` on the ThreadFactory returned from `backgroundThreadFactory()`.

  This method can currently only be used by backends.

  Throws:
    `ApiProxy.FeatureNotAvailableException` - If this application cannot use this feature.
    `ApiProxy.CancelledException` - If the request was interrupted while creating the new thread.
    `ApiProxy.ApiDeadlineExceededException` - If creation of the new thread took too long.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD