Thread Thread Class

Definition

A Thread is a concurrent unit of execution.

[Android.Runtime.Register("java/lang/Thread", ApiSince=1, DoNotGenerateAcw=true)]
public class Thread : Java.Lang.Object, IDisposable, Java.Lang.IRunnable
type Thread = class
    inherit Object
    interface IRunnable
    interface IJavaObject
    interface IDisposable
Inheritance
Derived
Attributes
Implements

Remarks

Android platform documentation

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

Thread() Thread()

Constructs a new Thread with no Runnable object and a newly generated name.

Thread(Action) Thread(Action)
Thread(Action, String) Thread(Action, String)
Thread(IntPtr, JniHandleOwnership) Thread(IntPtr, JniHandleOwnership)

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

Thread(IRunnable) Thread(IRunnable)

Constructs a new Thread with a Runnable object and a newly generated name.

Thread(IRunnable, String) Thread(IRunnable, String)

Constructs a new Thread with a Runnable object and name provided.

Thread(String) Thread(String)

Constructs a new Thread with no Runnable object and the name provided.

Thread(ThreadGroup, Action) Thread(ThreadGroup, Action)
Thread(ThreadGroup, Action, String) Thread(ThreadGroup, Action, String)
Thread(ThreadGroup, Action, String, Int64) Thread(ThreadGroup, Action, String, Int64)
Thread(ThreadGroup, IRunnable) Thread(ThreadGroup, IRunnable)

Constructs a new Thread with a Runnable object and a newly generated name.

Thread(ThreadGroup, IRunnable, String) Thread(ThreadGroup, IRunnable, String)

Constructs a new Thread with a Runnable object, the given name and belonging to the ThreadGroup passed as parameter.

Thread(ThreadGroup, IRunnable, String, Int64) Thread(ThreadGroup, IRunnable, String, Int64)

Constructs a new Thread with a Runnable object, the given name and belonging to the ThreadGroup passed as parameter.

Thread(ThreadGroup, String) Thread(ThreadGroup, String)

Constructs a new Thread with no Runnable object, the given name and belonging to the ThreadGroup passed as parameter.

Fields

MaxPriority MaxPriority

The maximum priority value allowed for a thread.

MinPriority MinPriority

The minimum priority value allowed for a thread.

NormPriority NormPriority

The normal (default) priority value assigned to the main thread.

Properties

AllStackTraces AllStackTraces

Returns a map of all the currently live threads to their stack traces.

Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
ContextClassLoader ContextClassLoader

Returns the context ClassLoader for this Thread.

Daemon Daemon

Tests whether this is a daemon thread.

DefaultUncaughtExceptionHandler DefaultUncaughtExceptionHandler

Returns the default exception handler that's executed when uncaught exception terminates a thread.

Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
Id Id

Returns the thread's identifier.

IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
IsAlive IsAlive

Returns true if the receiver has already been started and still runs code (hasn't died yet).

IsInterrupted IsInterrupted

Returns a boolean indicating whether the receiver has a pending interrupt request (true) or not ( false)

JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
Name Name

Returns the name of the Thread.

PeerReference PeerReference Inherited from Object
Priority Priority

Returns the priority of the Thread.

ThreadGroup ThreadGroup

Returns the ThreadGroup to which this Thread belongs.

ThresholdClass ThresholdClass

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

ThresholdType ThresholdType

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

UncaughtExceptionHandler UncaughtExceptionHandler

Returns the thread's uncaught exception handler.

Methods

ActiveCount() ActiveCount()

Returns the number of active Threads in the running Thread's group and its subgroups.

CheckAccess() CheckAccess()

Does nothing.

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
CountStackFrames() CountStackFrames()

Returns the number of stack frames in this thread.

CurrentThread() CurrentThread()

Returns the Thread of the caller, that is, the current Thread.

Destroy() Destroy()

Throws UnsupportedOperationException.

Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
DumpStack() DumpStack()

Prints to the standard error stream a text representation of the current stack for this Thread.

Enumerate(Thread[]) Enumerate(Thread[])

Copies an array with all Threads which are in the same ThreadGroup as the receiver - and subgroups - into the array threads passed as parameter.

Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
GetStackTrace() GetStackTrace()

Returns an array of StackTraceElement representing the current thread's stack.

GetState() GetState()

Returns the current state of the Thread.

HoldsLock(Object) HoldsLock(Object)

Indicates whether the current Thread has a monitor lock on the specified object.

Interrupt() Interrupt()

Posts an interrupt request to this Thread.

Interrupted() Interrupted()

Returns a boolean indicating whether the current Thread ( currentThread()) has a pending interrupt request ( true) or not (false).

JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Join() Join()

Blocks the current Thread (Thread.currentThread()) until the receiver finishes its execution and dies.

Join(Int64) Join(Int64)

Blocks the current Thread (Thread.currentThread()) until the receiver finishes its execution and dies or the specified timeout expires, whatever happens first.

Join(Int64, Int32) Join(Int64, Int32)

Blocks the current Thread (Thread.currentThread()) until the receiver finishes its execution and dies or the specified timeout expires, whatever happens first.

Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
Resume() Resume()

Throws UnsupportedOperationException.

Run() Run()

Calls the run() method of the Runnable object the receiver holds.

SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
Sleep(Int64) Sleep(Int64)

Causes the thread which sent this message to sleep for the given interval of time (given in milliseconds).

Sleep(Int64, Int32) Sleep(Int64, Int32)

Causes the thread which sent this message to sleep for the given interval of time (given in milliseconds and nanoseconds).

Start() Start()

Starts the new Thread of execution.

Stop() Stop()

Requests the receiver Thread to stop and throw ThreadDeath.

Stop(Throwable) Stop(Throwable)

Throws UnsupportedOperationException.

Suspend() Suspend()

Throws UnsupportedOperationException.

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

Returns a string containing a concise, human-readable description of this object.

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

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Yield() Yield()

Causes the calling Thread to yield execution time to another Thread that is ready to run.

Explicit Interface Implementations

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

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to