Apple Java Extensions

com.apple.concurrent
Class Dispatch

java.lang.Object
  extended by com.apple.concurrent.Dispatch

public final class Dispatch
extends java.lang.Object

Factory for Executors and ExecutorServices backed by libdispatch. Access is controlled through the Dispatch.getInstance() method, because performed tasks occur on threads owned by libdispatch. These threads are not owned by any particular AppContext or have any specific context classloader installed.

Since:
Java for Mac OS X 10.6 Update 2

Nested Class Summary
static class Dispatch.Priority
          The priorities of the three default asynchronous queues.
 
Method Summary
 java.util.concurrent.ExecutorService createSerialExecutor(java.lang.String label)
          Creates an ExecutorService that performs tasks synchronously in FIFO order.
 java.util.concurrent.Executor getAsyncExecutor(Dispatch.Priority priority)
          Creates an Executor that performs tasks asynchronously.
 java.util.concurrent.Executor getBlockingMainQueueExecutor()
          Returns an Executor that performs the provided Runnables on the main queue of the process.
static Dispatch getInstance()
          Factory method returns an instnace of Dispatch if supported by the underlying operating system, and if the caller's security manager permits "canInvokeInSystemThreadGroup".
 java.util.concurrent.Executor getNonBlockingMainQueueExecutor()
          Returns an Executor that performs the provided Runnables on the main queue of the process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Dispatch getInstance()
Factory method returns an instnace of Dispatch if supported by the underlying operating system, and if the caller's security manager permits "canInvokeInSystemThreadGroup".

Returns:
a factory instance of Dispatch, or null if not available

getAsyncExecutor

public java.util.concurrent.Executor getAsyncExecutor(Dispatch.Priority priority)
Creates an Executor that performs tasks asynchronously. The Executor cannot be shutdown, and enqueued Runnables cannot be canceled. Passing null returns the Priority.NORMAL Executor.

Parameters:
priority - - the priority of the returned Executor
Returns:
an asynchronous Executor

createSerialExecutor

public java.util.concurrent.ExecutorService createSerialExecutor(java.lang.String label)
Creates an ExecutorService that performs tasks synchronously in FIFO order. Useful to protect a resource against concurrent modification, in lieu of a lock. Passing null returns an ExecutorService with a uniquely labeled queue.

Parameters:
label - - a label to name the queue, shown in several debugging tools
Returns:
a synchronous ExecutorService

getNonBlockingMainQueueExecutor

public java.util.concurrent.Executor getNonBlockingMainQueueExecutor()
Returns an Executor that performs the provided Runnables on the main queue of the process. Runnables submitted to this Executor will not run until the AWT is started or another native toolkit is running a CFRunLoop or NSRunLoop on the main thread. Submitting a Runnable to this Executor does not wait for the Runnable to complete.

Returns:
an asynchronous Executor that is backed by the main queue

getBlockingMainQueueExecutor

public java.util.concurrent.Executor getBlockingMainQueueExecutor()
Returns an Executor that performs the provided Runnables on the main queue of the process. Runnables submitted to this Executor will not run until the AWT is started or another native toolkit is running a CFRunLoop or NSRunLoop on the main thread. Submitting a Runnable to this Executor will block until the Runnable has completed.

Returns:
an Executor that is backed by the main queue

Apple Java Extensions

To file bugs or suggest feature enhancements for the Java implementation in Mac OS X, visit the Apple Developer Connection Bug Reporter website. File bugs under the Java (new bugs) component, version X.

Additional documentation for Java development on Mac OS X is available online at the Java Developer Documentation website.

© Apple Computer, Inc. October 2010