
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Methods of the Thread Class
Some of the popular methods of a Thread class is start, sleep, jon, and abort. Let us see the complete list of methods −
Sr.No. | Method & Description |
---|---|
1 | public void Abort() Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread. |
2 | public static LocalDataStoreSlot AllocateDataSlot() Allocates an unnamed data slot on all the threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead. |
3 | public static LocalDataStoreSlot AllocateNamedDataSlot(string name) Allocates a named data slot on all threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead. |
4 | public static void BeginCriticalRegion() Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain. |
5 | public static void BeginThreadAffinity() Notifies a host that managed code is about to execute instructions that depend on the identity of the current physical operating system thread. |
6 | public static void EndCriticalRegion() Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception are limited to the current task. |
7 | public static void EndThreadAffinity() Notifies a host that managed code has finished executing instructions that depend on the identity of the current physical operating system thread. |
8 | public static void FreeNamedDataSlot(string name) Eliminates the association between a name and a slot, for all threads in the process. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead. |
9 | public static Object GetData(LocalDataStoreSlot slot) Retrieves the value from the specified slot on the current thread, within the current thread's current domain. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead. |
10 | public static AppDomain GetDomain() Returns the current domain in which the current thread is running. |
11 | public static AppDomain GetDomainID() Returns a unique application domain identifier |
12 | public static LocalDataStoreSlot GetNamedDataSlot(string name) Looks up a named data slot. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead. |
13 | public void Interrupt() Interrupts a thread that is in the WaitSleepJoin thread state. |
14 | public void Join() Blocks the calling thread until a thread terminates, while continuing to perform standard COM and SendMessage pumping. This method has different overloaded forms. |
15 | public static void MemoryBarrier() Synchronizes memory access as follows − The processor executing the current thread cannot reorder instructions in such a way that memory accesses prior to the call to MemoryBarrier execute after memory accesses that follow the call to MemoryBarrier. |
16 | public static void ResetAbort() Cancels an Abort requested for the current thread. |
17 | public static void SetData(LocalDataStoreSlot slot, Object data) Sets the data in the specified slot on the currently running thread, for that thread's current domain. For better performance, use fields marked with the ThreadStaticAttribute attribute instead. |
18 | public void Start() Starts a thread. |
19 | public static void Sleep(int millisecondsTimeout) Makes the thread pause for a period of time. |
20 | public static void SpinWait(int iterations) Causes a thread to wait the number of times defined by the iterations parameter |
- Related Articles
- What are the methods and properties of the Thread class in C#?
- Properties of the Thread Class
- The join() method of Thread Class in Java
- What is the Thread class in Java?
- isAlive() method of Thread Class in Java programming
- Methods of the Matcher class in Java Regex
- Methods of the Pattern class in Java Regex
- What are the important methods of the SQLException class?
- Methods of StringBuffer class in Java.
- Methods of StringBuilder class in Java.
- Methods of StringTokenizer class in Java.
- Useful Methods of Integer Class in Ruby
- How to use isAlive() method of Thread class in Java?
- How to access the private methods of a class from outside of the class in Java?
- BitSet class methods in Java
