次の方法で共有


RecursiveTask Class

Definition

A recursive result-bearing ForkJoinTask.

[Android.Runtime.Register("java/util/concurrent/RecursiveTask", DoNotGenerateAcw=true)]
[Java.Interop.JavaTypeParameters(new System.String[] { "V" })]
public abstract class RecursiveTask : Java.Util.Concurrent.ForkJoinTask
[<Android.Runtime.Register("java/util/concurrent/RecursiveTask", DoNotGenerateAcw=true)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "V" })>]
type RecursiveTask = class
    inherit ForkJoinTask
Inheritance
RecursiveTask
Attributes

Remarks

A recursive result-bearing ForkJoinTask.

For a classic example, here is a task computing Fibonacci numbers:

{@code
            class Fibonacci extends RecursiveTask<Integer> {
              final int n;
              Fibonacci(int n) { this.n = n; }
              protected Integer compute() {
                if (n <= 1)
                  return n;
                Fibonacci f1 = new Fibonacci(n - 1);
                f1.fork();
                Fibonacci f2 = new Fibonacci(n - 2);
                return f2.compute() + f1.join();
              }
            }}

However, besides being a dumb way to compute Fibonacci functions (there is a simple fast linear algorithm that you'd use in practice), this is likely to perform poorly because the smallest subtasks are too small to be worthwhile splitting up. Instead, as is the case for nearly all fork/join applications, you'd pick some minimum granularity size (for example 10 here) for which you always sequentially solve rather than subdividing.

Added in 1.7.

Java documentation for java.util.concurrent.RecursiveTask.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

RecursiveTask()

Constructor for subclasses to call.

RecursiveTask(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Exception

Returns the exception thrown by the base computation, or a CancellationException if cancelled, or null if none or if the method has not yet completed.

(Inherited from ForkJoinTask)
ForkJoinTaskTag

Returns the tag for this task.

(Inherited from ForkJoinTask)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsCancelled

Returns true if this task was cancelled before it completed normally.

(Inherited from ForkJoinTask)
IsCompletedAbnormally

Returns true if this task threw an exception or was cancelled.

(Inherited from ForkJoinTask)
IsCompletedNormally

Returns true if this task completed without throwing an exception and was not cancelled.

(Inherited from ForkJoinTask)
IsDone

Returns true if this task completed.

(Inherited from ForkJoinTask)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
RawRawResult

Returns the result that would be returned by Join(), even if this task completed abnormally, or null if this task is not known to have been completed.

(Inherited from ForkJoinTask)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Cancel(Boolean)

Attempts to cancel execution of this task.

(Inherited from ForkJoinTask)
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CompareAndSetForkJoinTaskTag(Int16, Int16)

Atomically conditionally sets the tag value for this task.

(Inherited from ForkJoinTask)
Complete(Object)

Completes this task, and if not already aborted or cancelled, returning the given value as the result of subsequent invocations of join and related operations.

(Inherited from ForkJoinTask)
CompleteExceptionally(Throwable)

Completes this task abnormally, and if not already aborted or cancelled, causes it to throw the given exception upon join and related operations.

(Inherited from ForkJoinTask)
Compute()

The main computation performed by this task.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Exec()

Implements execution conventions for RecursiveTask.

Fork()

Arranges to asynchronously execute this task in the pool the current task is running in, if applicable, or using the ForkJoinPool#commonPool() if not #inForkJoinPool.

(Inherited from ForkJoinTask)
Get()

Waits if necessary for the computation to complete, and then retrieves its result.

(Inherited from ForkJoinTask)
Get(Int64, TimeUnit)

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

(Inherited from ForkJoinTask)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Invoke()

Commences performing this task, awaits its completion if necessary, and returns its result, or throws an (unchecked) RuntimeException or Error if the underlying computation did so.

(Inherited from ForkJoinTask)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Join()

Returns the result of the computation when it #isDone is done.

(Inherited from ForkJoinTask)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
QuietlyComplete()

Completes this task normally without setting a value.

(Inherited from ForkJoinTask)
QuietlyInvoke()

Commences performing this task and awaits its completion if necessary, without returning its result or throwing its exception.

(Inherited from ForkJoinTask)
QuietlyJoin()

Joins this task, without returning its result or throwing its exception.

(Inherited from ForkJoinTask)
Reinitialize()

Resets the internal bookkeeping state of this task, allowing a subsequent fork.

(Inherited from ForkJoinTask)
SetForkJoinTaskTag(Int16)

Atomically sets the tag value for this task and returns the old value.

(Inherited from ForkJoinTask)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetRawResult(Object)

Forces the given value to be returned as a result.

(Inherited from ForkJoinTask)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
TryUnfork()

Tries to unschedule this task for execution.

(Inherited from ForkJoinTask)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
GetAsync(IFuture, Int64, TimeUnit)
GetAsync(IFuture)

Applies to