Thread 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
스레드를 만들고 제어하며, 해당 속성을 설정하고, 상태를 가져옵니다.
public ref class Thread sealed : System::Runtime::ConstrainedExecution::CriticalFinalizerObject
public ref class Thread sealed
public ref class Thread sealed : System::Runtime::InteropServices::_Thread
public ref class Thread sealed : System::Runtime::ConstrainedExecution::CriticalFinalizerObject, System::Runtime::InteropServices::_Thread
public sealed class Thread : System.Runtime.ConstrainedExecution.CriticalFinalizerObject
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class Thread
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class Thread : System.Runtime.InteropServices._Thread
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class Thread : System.Runtime.ConstrainedExecution.CriticalFinalizerObject, System.Runtime.InteropServices._Thread
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class Thread : System.Runtime.ConstrainedExecution.CriticalFinalizerObject
type Thread = class
inherit CriticalFinalizerObject
[<System.Runtime.InteropServices.ComVisible(true)>]
type Thread = class
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type Thread = class
interface _Thread
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type Thread = class
inherit CriticalFinalizerObject
interface _Thread
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type Thread = class
inherit CriticalFinalizerObject
Public NotInheritable Class Thread
Inherits CriticalFinalizerObject
Public NotInheritable Class Thread
Public NotInheritable Class Thread
Implements _Thread
Public NotInheritable Class Thread
Inherits CriticalFinalizerObject
Implements _Thread
- 상속
- 상속
-
Thread
- 특성
- 구현
예제
다음 예제에서는 간단한 스레딩 기능을 보여 줍니다.
// [C++]
// Compile using /clr option.
using namespace System;
using namespace System::Threading;
// Simple threading scenario: Start a Shared method running
// on a second thread.
public ref class ThreadExample
{
public:
// The ThreadProc method is called when the thread starts.
// It loops ten times, writing to the console and yielding
// the rest of its time slice each time, and then ends.
static void ThreadProc()
{
for ( int i = 0; i < 10; i++ )
{
Console::Write( "ThreadProc: " );
Console::WriteLine( i );
// Yield the rest of the time slice.
Thread::Sleep( 0 );
}
}
};
int main()
{
Console::WriteLine( "Main thread: Start a second thread." );
// Create the thread, passing a ThreadStart delegate that
// represents the ThreadExample::ThreadProc method. For a
// delegate representing a static method, no object is
// required.
Thread^ oThread = gcnew Thread( gcnew ThreadStart( &ThreadExample::ThreadProc ) );
// Start ThreadProc. Note that on a uniprocessor, the new
// thread does not get any processor time until the main thread
// is preempted or yields. Uncomment the Thread::Sleep that
// follows oThread->Start() to see the difference.
oThread->Start();
//Thread::Sleep(0);
for ( int i = 0; i < 4; i++ )
{
Console::WriteLine( "Main thread: Do some work." );
Thread::Sleep( 0 );
}
Console::WriteLine( "Main thread: Call Join(), to wait until ThreadProc ends." );
oThread->Join();
Console::WriteLine( "Main thread: ThreadProc.Join has returned. Press Enter to end program." );
Console::ReadLine();
return 0;
}
using System;
using System.Threading;
// Simple threading scenario: Start a static method running
// on a second thread.
public class ThreadExample {
// The ThreadProc method is called when the thread starts.
// It loops ten times, writing to the console and yielding
// the rest of its time slice each time, and then ends.
public static void ThreadProc() {
for (int i = 0; i < 10; i++) {
Console.WriteLine("ThreadProc: {0}", i);
// Yield the rest of the time slice.
Thread.Sleep(0);
}
}
public static void Main() {
Console.WriteLine("Main thread: Start a second thread.");
// The constructor for the Thread class requires a ThreadStart
// delegate that represents the method to be executed on the
// thread. C# simplifies the creation of this delegate.
Thread t = new Thread(new ThreadStart(ThreadProc));
// Start ThreadProc. Note that on a uniprocessor, the new
// thread does not get any processor time until the main thread
// is preempted or yields. Uncomment the Thread.Sleep that
// follows t.Start() to see the difference.
t.Start();
//Thread.Sleep(0);
for (int i = 0; i < 4; i++) {
Console.WriteLine("Main thread: Do some work.");
Thread.Sleep(0);
}
Console.WriteLine("Main thread: Call Join(), to wait until ThreadProc ends.");
t.Join();
Console.WriteLine("Main thread: ThreadProc.Join has returned. Press Enter to end program.");
Console.ReadLine();
}
}
Imports System.Threading
' Simple threading scenario: Start a Shared method running
' on a second thread.
Public Class ThreadExample
' The ThreadProc method is called when the thread starts.
' It loops ten times, writing to the console and yielding
' the rest of its time slice each time, and then ends.
Public Shared Sub ThreadProc()
Dim i As Integer
For i = 0 To 9
Console.WriteLine("ThreadProc: {0}", i)
' Yield the rest of the time slice.
Thread.Sleep(0)
Next
End Sub
Public Shared Sub Main()
Console.WriteLine("Main thread: Start a second thread.")
' The constructor for the Thread class requires a ThreadStart
' delegate. The Visual Basic AddressOf operator creates this
' delegate for you.
Dim t As New Thread(AddressOf ThreadProc)
' Start ThreadProc. Note that on a uniprocessor, the new
' thread does not get any processor time until the main thread
' is preempted or yields. Uncomment the Thread.Sleep that
' follows t.Start() to see the difference.
t.Start()
'Thread.Sleep(0)
Dim i As Integer
For i = 1 To 4
Console.WriteLine("Main thread: Do some work.")
Thread.Sleep(0)
Next
Console.WriteLine("Main thread: Call Join(), to wait until ThreadProc ends.")
t.Join()
Console.WriteLine("Main thread: ThreadProc.Join has returned. Press Enter to end program.")
Console.ReadLine()
End Sub
End Class
이 코드는 다음과 유사한 출력을 생성 합니다.
[VB, C++, C#]
Main thread: Start a second thread.
Main thread: Do some work.
ThreadProc: 0
Main thread: Do some work.
ThreadProc: 1
Main thread: Do some work.
ThreadProc: 2
Main thread: Do some work.
ThreadProc: 3
Main thread: Call Join(), to wait until ThreadProc ends.
ThreadProc: 4
ThreadProc: 5
ThreadProc: 6
ThreadProc: 7
ThreadProc: 8
ThreadProc: 9
Main thread: ThreadProc.Join has returned. Press Enter to end program.
설명
프로세스가 시작 되 면 공용 언어 런타임 애플리케이션 코드를 실행 하는 단일 포그라운드 스레드를 자동으로 만듭니다. 프로세스는이 주 포그라운드 스레드와 함께 프로세스와 관련 된 프로그램 코드의 일부를 실행 하는 스레드를 하나 이상 만들 수 있습니다. 이러한 스레드는 포그라운드 또는 백그라운드에서 실행할 수 있습니다. 또한 클래스를 사용 하 여 ThreadPool 공용 언어 런타임에 의해 관리 되는 작업자 스레드에 대해 코드를 실행할 수 있습니다.
단원 내용
스레드 시작
스레드 개체 검색
포그라운드 및 백그라운드 스레드
문화권 및 스레드
스레드에 대 한 정보 가져오기 및 제어
스레드 시작
스레드가 클래스 생성자에서 실행할 메서드를 나타내는 대리자를 제공 하 여 스레드를 시작 합니다. 그런 다음 메서드를 호출 Start 하 여 실행을 시작 합니다.
Thread생성자는 실행할 메서드에 인수를 전달할 수 있는지 여부에 따라 두 개의 대리자 형식 중 하나를 사용할 수 있습니다.
메서드에 인수가 없으면 ThreadStart 대리자를 생성자에 전달 합니다. 다음 서명이 있습니다.
public delegate void ThreadStart()
Public Delegate Sub ThreadStart()
다음 예제에서는 메서드를 실행 하는 스레드를 만들고 시작 합니다
ExecuteInForeground
. 메서드는 일부 스레드 속성에 대 한 정보를 표시 한 다음 0.5 초 동안 일시 중지 하 고 경과 된 시간 (초)을 표시 하는 루프를 실행 합니다. 스레드가 5 초 이상 실행 되 면 루프가 종료 되 고 스레드가 실행을 종료 합니다.using System; using System.Diagnostics; using System.Threading; public class Example { public static void Main() { var th = new Thread(ExecuteInForeground); th.Start(); Thread.Sleep(1000); Console.WriteLine("Main thread ({0}) exiting...", Thread.CurrentThread.ManagedThreadId); } private static void ExecuteInForeground() { var sw = Stopwatch.StartNew(); Console.WriteLine("Thread {0}: {1}, Priority {2}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.ThreadState, Thread.CurrentThread.Priority); do { Console.WriteLine("Thread {0}: Elapsed {1:N2} seconds", Thread.CurrentThread.ManagedThreadId, sw.ElapsedMilliseconds / 1000.0); Thread.Sleep(500); } while (sw.ElapsedMilliseconds <= 5000); sw.Stop(); } } // The example displays output like the following: // Thread 3: Running, Priority Normal // Thread 3: Elapsed 0.00 seconds // Thread 3: Elapsed 0.51 seconds // Main thread (1) exiting... // Thread 3: Elapsed 1.02 seconds // Thread 3: Elapsed 1.53 seconds // Thread 3: Elapsed 2.05 seconds // Thread 3: Elapsed 2.55 seconds // Thread 3: Elapsed 3.07 seconds // Thread 3: Elapsed 3.57 seconds // Thread 3: Elapsed 4.07 seconds // Thread 3: Elapsed 4.58 seconds
Imports System.Diagnostics Imports System.Threading Module Example Public Sub Main() Dim th As New Thread(AddressOf ExecuteInForeground) th.Start() Thread.Sleep(1000) Console.WriteLine("Main thread ({0}) exiting...", Thread.CurrentThread.ManagedThreadId) End Sub Private Sub ExecuteInForeground() Dim start As DateTime = DateTime.Now Dim sw As Stopwatch = Stopwatch.StartNew() Console.WriteLine("Thread {0}: {1}, Priority {2}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.ThreadState, Thread.CurrentThread.Priority) Do Console.WriteLine("Thread {0}: Elapsed {1:N2} seconds", Thread.CurrentThread.ManagedThreadId, sw.ElapsedMilliseconds / 1000) Thread.Sleep(500) Loop While sw.ElapsedMilliseconds <= 5000 sw.Stop() End Sub End Module ' The example displays output like the following: ' Thread 3: Running, Priority Normal ' Thread 3: Elapsed 0.00 seconds ' Thread 3: Elapsed 0.51 seconds ' Main thread (1) exiting... ' Thread 3: Elapsed 1.02 seconds ' Thread 3: Elapsed 1.53 seconds ' Thread 3: Elapsed 2.05 seconds ' Thread 3: Elapsed 2.55 seconds ' Thread 3: Elapsed 3.07 seconds ' Thread 3: Elapsed 3.57 seconds ' Thread 3: Elapsed 4.07 seconds ' Thread 3: Elapsed 4.58 seconds
메서드에 인수가 있는 경우 ParameterizedThreadStart 대리자를 생성자에 전달 합니다. 다음 서명이 있습니다.
public delegate void ParameterizedThreadStart(object obj)
Public Delegate Sub ParameterizedThreadStart(obj As Object)
대리자가 실행 하는 메서드는 (c #의 경우) 매개 변수를 적절 한 형식으로 캐스팅 (c #의 경우) 하거나 변환 (Visual Basic) 할 수 있습니다.
다음 예제는 생성자를 호출 한다는 점을 제외 하 고 이전 예제와 동일 합니다 Thread(ParameterizedThreadStart) . 이 버전의
ExecuteInForeground
메서드는 루프가 실행 되는 대략적인 시간 (밀리초)을 나타내는 단일 매개 변수를 포함 합니다.using System; using System.Diagnostics; using System.Threading; public class Example { public static void Main() { var th = new Thread(ExecuteInForeground); th.Start(4500); Thread.Sleep(1000); Console.WriteLine("Main thread ({0}) exiting...", Thread.CurrentThread.ManagedThreadId); } private static void ExecuteInForeground(Object obj) { int interval; try { interval = (int) obj; } catch (InvalidCastException) { interval = 5000; } var sw = Stopwatch.StartNew(); Console.WriteLine("Thread {0}: {1}, Priority {2}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.ThreadState, Thread.CurrentThread.Priority); do { Console.WriteLine("Thread {0}: Elapsed {1:N2} seconds", Thread.CurrentThread.ManagedThreadId, sw.ElapsedMilliseconds / 1000.0); Thread.Sleep(500); } while (sw.ElapsedMilliseconds <= interval); sw.Stop(); } } // The example displays output like the following: // Thread 3: Running, Priority Normal // Thread 3: Elapsed 0.00 seconds // Thread 3: Elapsed 0.52 seconds // Main thread (1) exiting... // Thread 3: Elapsed 1.03 seconds // Thread 3: Elapsed 1.55 seconds // Thread 3: Elapsed 2.06 seconds // Thread 3: Elapsed 2.58 seconds // Thread 3: Elapsed 3.09 seconds // Thread 3: Elapsed 3.61 seconds // Thread 3: Elapsed 4.12 seconds
Imports System.Diagnostics Imports System.Threading Module Example Public Sub Main() Dim th As New Thread(AddressOf ExecuteInForeground) th.Start(4500) Thread.Sleep(1000) Console.WriteLine("Main thread ({0}) exiting...", Thread.CurrentThread.ManagedThreadId) End Sub Private Sub ExecuteInForeground(obj As Object) Dim interval As Integer If IsNumeric(obj) Then interval = CInt(obj) Else interval = 5000 End If Dim start As DateTime = DateTime.Now Dim sw As Stopwatch = Stopwatch.StartNew() Console.WriteLine("Thread {0}: {1}, Priority {2}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.ThreadState, Thread.CurrentThread.Priority) Do Console.WriteLine("Thread {0}: Elapsed {1:N2} seconds", Thread.CurrentThread.ManagedThreadId, sw.ElapsedMilliseconds / 1000) Thread.Sleep(500) Loop While sw.ElapsedMilliseconds <= interval sw.Stop() End Sub End Module ' The example displays output like the following: ' Thread 3: Running, Priority Normal ' Thread 3: Elapsed 0.00 seconds ' Thread 3: Elapsed 0.52 seconds ' Main thread (1) exiting... ' Thread 3: Elapsed 1.03 seconds ' Thread 3: Elapsed 1.55 seconds ' Thread 3: Elapsed 2.06 seconds ' Thread 3: Elapsed 2.58 seconds ' Thread 3: Elapsed 3.09 seconds ' Thread 3: Elapsed 3.61 seconds ' Thread 3: Elapsed 4.12 seconds
스레드를 시작한 후에는 개체에 대 한 참조를 유지할 필요가 없습니다 Thread . 스레드는 스레드 프로시저가 완료 될 때까지 계속 실행 됩니다.
스레드 개체 검색
정적 ( Shared
Visual Basic) 속성을 사용 하 여 CurrentThread 스레드가 실행 중인 코드에서 현재 실행 중인 스레드에 대 한 참조를 검색할 수 있습니다. 다음 예제에서는 CurrentThread 속성을 기본 애플리케이션 스레드, 다른 포그라운드 스레드, 백그라운드 스레드 및 스레드 풀 스레드에 대 한 정보를 표시 합니다.
using System;
using System.Threading;
public class Example
{
static Object obj = new Object();
public static void Main()
{
ThreadPool.QueueUserWorkItem(ShowThreadInformation);
var th1 = new Thread(ShowThreadInformation);
th1.Start();
var th2 = new Thread(ShowThreadInformation);
th2.IsBackground = true;
th2.Start();
Thread.Sleep(500);
ShowThreadInformation(null);
}
private static void ShowThreadInformation(Object state)
{
lock (obj) {
var th = Thread.CurrentThread;
Console.WriteLine("Managed thread #{0}: ", th.ManagedThreadId);
Console.WriteLine(" Background thread: {0}", th.IsBackground);
Console.WriteLine(" Thread pool thread: {0}", th.IsThreadPoolThread);
Console.WriteLine(" Priority: {0}", th.Priority);
Console.WriteLine(" Culture: {0}", th.CurrentCulture.Name);
Console.WriteLine(" UI culture: {0}", th.CurrentUICulture.Name);
Console.WriteLine();
}
}
}
// The example displays output like the following:
// Managed thread #6:
// Background thread: True
// Thread pool thread: False
// Priority: Normal
// Culture: en-US
// UI culture: en-US
//
// Managed thread #3:
// Background thread: True
// Thread pool thread: True
// Priority: Normal
// Culture: en-US
// UI culture: en-US
//
// Managed thread #4:
// Background thread: False
// Thread pool thread: False
// Priority: Normal
// Culture: en-US
// UI culture: en-US
//
// Managed thread #1:
// Background thread: False
// Thread pool thread: False
// Priority: Normal
// Culture: en-US
// UI culture: en-US
Imports System.Threading
Module Example
Private lock As New Object()
Public Sub Main()
ThreadPool.QueueUserWorkItem(AddressOf ShowThreadInformation)
Dim th1 As New Thread(AddressOf ShowThreadInformation)
th1.Start()
Dim th2 As New Thread(AddressOf ShowThreadInformation)
th2.IsBackground = True
th2.Start()
Thread.Sleep(500)
ShowThreadInformation(Nothing)
End Sub
Private Sub ShowThreadInformation(state As Object)
SyncLock lock
Dim th As Thread = Thread.CurrentThread
Console.WriteLine("Managed thread #{0}: ", th.ManagedThreadId)
Console.WriteLine(" Background thread: {0}", th.IsBackground)
Console.WriteLine(" Thread pool thread: {0}", th.IsThreadPoolThread)
Console.WriteLine(" Priority: {0}", th.Priority)
Console.WriteLine(" Culture: {0}", th.CurrentCulture.Name)
Console.WriteLine(" UI culture: {0}", th.CurrentUICulture.Name)
Console.WriteLine()
End SyncLock
End Sub
End Module
' The example displays output like the following:
' ' Managed thread #6:
' Background thread: True
' Thread pool thread: False
' Priority: Normal
' Culture: en-US
' UI culture: en-US
'
' Managed thread #3:
' Background thread: True
' Thread pool thread: True
' Priority: Normal
' Culture: en-US
' UI culture: en-US
'
' Managed thread #4:
' Background thread: False
' Thread pool thread: False
' Priority: Normal
' Culture: en-US
' UI culture: en-US
'
' Managed thread #1:
' Background thread: False
' Thread pool thread: False
' Priority: Normal
' Culture: en-US
' UI culture: en-US
포그라운드 및 백그라운드 스레드
클래스의 인스턴스는 Thread 포그라운드 스레드 또는 백그라운드 스레드를 나타냅니다. 백그라운드 스레드는 포그라운드 스레드와 동일 합니다. 단, 백그라운드 스레드는 모든 포그라운드 스레드가 종료 된 경우 프로세스를 계속 실행 하지 않습니다. 모든 포그라운드 스레드가 중지 되 면 런타임은 모든 백그라운드 스레드를 중지 하 고 종료 됩니다.
기본적으로 다음 스레드는 포그라운드로 실행 됩니다.
기본 애플리케이션 스레드입니다.
클래스 생성자를 호출 하 여 만든 모든 스레드 Thread
다음 스레드는 기본적으로 백그라운드에서 실행 됩니다.
런타임에 의해 유지 관리 되는 작업자 스레드 풀 인 스레드 풀 스레드 클래스를 사용 하 여 스레드 풀을 구성 하 고 스레드 풀 스레드에서 작업을 예약할 수 있습니다 ThreadPool .
참고
작업 기반 비동기 작업은 스레드 풀 스레드에서 자동으로 실행 됩니다. 작업 기반 비동기 작업에서는 Task 및 클래스를 사용 Task<TResult> 하 여 작업 기반 비동기 패턴을 구현 합니다.
관리 되지 않는 코드에서 관리 되는 실행 환경으로 시작 하는 모든 스레드
언제 든 지 속성을 설정 하 여 백그라운드에서 실행 되도록 스레드를 변경할 수 있습니다 IsBackground . 백그라운드 스레드는 애플리케이션이 실행 되 고 있지만 종료 파일 시스템 변경 사항 또는 들어오는 소켓 연결을 모니터링 하는 등의 애플리케이션을 중지 되지는 않습니다 있다면 계속 해야 하는 모든 작업에 유용 합니다.
다음 예제에서는 포그라운드 스레드와 백그라운드 스레드 간의 차이점을 보여 줍니다. 스레드를 시작 하기 전에 백그라운드에서 실행 되도록 스레드를 설정 한다는 점을 제외 하 고는 스레드 시작 섹션의 첫 번째 예제와 같습니다. 출력에 표시 된 것 처럼 루프가 5 초 동안 실행 되기 전에 중단 됩니다.
using System;
using System.Diagnostics;
using System.Threading;
public class Example
{
public static void Main()
{
var th = new Thread(ExecuteInForeground);
th.IsBackground = true;
th.Start();
Thread.Sleep(1000);
Console.WriteLine("Main thread ({0}) exiting...",
Thread.CurrentThread.ManagedThreadId);
}
private static void ExecuteInForeground()
{
var sw = Stopwatch.StartNew();
Console.WriteLine("Thread {0}: {1}, Priority {2}",
Thread.CurrentThread.ManagedThreadId,
Thread.CurrentThread.ThreadState,
Thread.CurrentThread.Priority);
do {
Console.WriteLine("Thread {0}: Elapsed {1:N2} seconds",
Thread.CurrentThread.ManagedThreadId,
sw.ElapsedMilliseconds / 1000.0);
Thread.Sleep(500);
} while (sw.ElapsedMilliseconds <= 5000);
sw.Stop();
}
}
// The example displays output like the following:
// Thread 3: Background, Priority Normal
// Thread 3: Elapsed 0.00 seconds
// Thread 3: Elapsed 0.51 seconds
// Main thread (1) exiting...
Imports System.Diagnostics
Imports System.Threading
Module Example
Public Sub Main()
Dim th As New Thread(AddressOf ExecuteInForeground)
th.IsBackground = True
th.Start()
Thread.Sleep(1000)
Console.WriteLine("Main thread ({0}) exiting...", Thread.CurrentThread.ManagedThreadId)
End Sub
Private Sub ExecuteInForeground()
Dim start As DateTime = DateTime.Now
Dim sw As Stopwatch = Stopwatch.StartNew()
Console.WriteLine("Thread {0}: {1}, Priority {2}",
Thread.CurrentThread.ManagedThreadId,
Thread.CurrentThread.ThreadState,
Thread.CurrentThread.Priority)
Do
Console.WriteLine("Thread {0}: Elapsed {1:N2} seconds",
Thread.CurrentThread.ManagedThreadId,
sw.ElapsedMilliseconds / 1000)
Thread.Sleep(500)
Loop While sw.ElapsedMilliseconds <= 5000
sw.Stop()
End Sub
End Module
' The example displays output like the following:
' Thread 3: Background, Priority Normal
' Thread 3: Elapsed 0.00 seconds
' Thread 3: Elapsed 0.51 seconds
' Main thread (1) exiting...
문화권 및 스레드
각 스레드에는 속성이 나타내는 문화권과 CurrentCulture 속성이 나타내는 UI 문화권이 있습니다 CurrentUICulture . 현재 문화권은 구문 분석 및 형식 지정, 문자열 비교 및 정렬과 같은 문화권 구분 작업을 지원 하 고 스레드에서 사용 하는 쓰기 시스템과 일정을 제어 합니다. 현재 UI 문화권은 리소스 파일에서 문화권을 구분 하는 리소스 검색을 제공 합니다.
중요
CurrentCulture및 CurrentUICulture 속성은 현재 스레드가 아닌 다른 스레드에서 사용 하는 경우 안정적으로 작동 하지 않습니다. .NET Framework에서는 현재 스레드 이외의 스레드에 대해 이러한 속성을 설정 하는 것은 아니지만 이러한 속성을 읽는 것은 안정적입니다. .NET Core에서 InvalidOperationException 스레드가 다른 스레드에서 이러한 속성을 읽거나 쓰려고 하면이 throw 됩니다. 및 속성을 사용 하 여 CultureInfo.CurrentCulture 현재 문화권을 검색 하 고 설정 하는 것이 좋습니다 CultureInfo.CurrentUICulture .
새 스레드를 인스턴스화하면 해당 문화권 및 UI 문화권이 새 스레드가 생성 되는 스레드의 문화권 및 UI 문화권이 아니라 현재 시스템 문화권과 ui 문화권에 의해 정의 됩니다. 즉, 예를 들어, 현재 시스템 문화권이 영어 (미국) 및 기본 애플리케이션 스레드의 현재 문화권이 프랑스어 (프랑스) 호출 하 여 만든 새 스레드의 문화권은 Thread(ParameterizedThreadStart) 주 스레드에서 생성자 영어 (미국) 및 프랑스어 (프랑스) 되지 됩니다. 자세한 내용은 클래스 항목의 "문화권 및 스레드" 섹션을 참조 CultureInfo 하세요.
중요
이는 .NET Framework 4.6 이상 버전을 대상으로 하는 앱에 대해 비동기 작업을 실행 하는 스레드에는 적용 되지 않습니다 .이 경우 culture 및 UI 문화권이 비동기 작업 컨텍스트의 일부입니다. 기본적으로 비동기 작업이 실행 되는 스레드는 비동기 작업이 시작 된 스레드의 문화권과 UI 문화권을 상속 합니다. 자세한 내용은 CultureInfo 클래스 항목의 “문화권 및 작업 기반 비동기 작업” 섹션을 참조하세요.
하나를 수행 하면 동일한 문화권 및 UI 문화권 공유 애플리케이션에서 실행 중의 모든 스레드가 되도록 합니다.
CultureInfo해당 문화권을 나타내는 개체를 ParameterizedThreadStart 대리자 또는 메서드에 전달할 수 있습니다 ThreadPool.QueueUserWorkItem(WaitCallback, Object) .
.NET Framework 4.5 이상 버전에서 실행 되는 앱의 경우 및 속성의 값을 설정 하 여 응용 프로그램 도메인에서 만들어진 모든 스레드에 할당할 문화권 및 UI 문화권을 정의할 수 있습니다 CultureInfo.DefaultThreadCurrentCulture CultureInfo.DefaultThreadCurrentUICulture . 이는 응용 프로그램 별 도메인 설정입니다.
자세한 내용 및 예제는 클래스 항목의 "문화권 및 스레드" 섹션을 참조 CultureInfo 하세요.
스레드에 대 한 정보 가져오기 및 제어
스레드에 대 한 정보를 제공 하는 다양 한 속성 값을 검색할 수 있습니다. 경우에 따라이 속성 값을 설정 하 여 스레드 작업을 제어할 수도 있습니다. 이러한 스레드 속성은 다음과 같습니다.
이름 Name 는 스레드를 식별 하는 데 사용할 수 있는 한 번의 쓰기 속성입니다. 기본값은
null
합니다.메서드를 호출 하 여 검색할 수 있는 해시 코드 GetHashCode 입니다. 스레드를 고유 하 게 식별 하려면 해시 코드를 사용할 수 있습니다. 스레드 수명 동안 해당 해시 코드 값을 가져온 애플리케이션 도메인에 관계 없이 다른 스레드에서 값과 충돌 하지 않습니다.
스레드 ID입니다. 읽기 전용 속성의 값은 ManagedThreadId 런타임에 의해 할당 되 고 해당 프로세스 내에서 스레드를 고유 하 게 식별 합니다.
참고
관리되지 않는 호스트가 관리되는 스레드와 관리되지 않는 스레드 간의 관계를 제어할 수 있으므로 운영 체제 ThreadId 는 관리되는 스레드에 대한 고정 관계를 포함하지 않습니다. 특히 정교한 호스트는 CLR 호스팅 API 를 사용 하 여 동일한 운영 체제 스레드에 대해 여러 관리 되는 스레드를 예약 하거나 다른 운영 체제 스레드 간에 관리 되는 스레드를 이동할 수 있습니다.
스레드의 현재 상태입니다. 존재 기간이 지속 되는 동안 스레드는 항상 속성으로 정의 된 하나 이상의 상태에 ThreadState 있습니다.
속성에 의해 정의 되는 예약 우선 순위 수준입니다 ThreadPriority . 스레드의 우선 순위를 요청 하도록이 값을 설정할 수 있지만 운영 체제에서는이 값을 적용 하지 않을 수 있습니다.
IsThreadPoolThread스레드가 스레드 풀 스레드 인지 여부를 나타내는 읽기 전용 속성입니다.
IsBackground 속성 자세한 내용은 전경 및 백그라운드 스레드 섹션을 참조 하세요.
생성자
Thread(ParameterizedThreadStart) |
스레드가 시작될 때 개체가 스레드로 전달될 수 있도록 하는 대리자를 지정하여 Thread 클래스의 새 인스턴스를 초기화합니다. |
Thread(ParameterizedThreadStart, Int32) |
스레드가 시작될 때 스레드로 개체가 전달될 수 있도록 하는 대리자를 지정하고 스레드의 최대 스택 크기를 지정하여 Thread 클래스의 새 인스턴스를 초기화합니다. |
Thread(ThreadStart) |
Thread 클래스의 새 인스턴스를 초기화합니다. |
Thread(ThreadStart, Int32) |
스레드의 최대 스택 크기를 지정하여 Thread 클래스의 새 인스턴스를 초기화합니다. |
속성
ApartmentState |
사용되지 않습니다.
사용되지 않습니다.
사용되지 않습니다.
이 스레드의 아파트 상태를 가져오거나 설정합니다. |
CurrentContext |
스레드가 실행 중인 현재 컨텍스트를 가져옵니다. |
CurrentCulture |
현재 스레드에 대한 문화권을 가져오거나 설정합니다. |
CurrentPrincipal |
스레드의 현재 보안 주체(역할 기반 보안용)를 가져오거나 설정합니다. |
CurrentThread |
현재 실행 중인 스레드를 가져옵니다. |
CurrentUICulture |
리소스 관리자가 런타임에 문화권 관련 리소스를 찾기 위해 사용하는 현재 문화권을 가져오거나 설정합니다. |
ExecutionContext |
현재 스레드의 다양한 컨텍스트 정보를 포함하는 ExecutionContext 개체를 가져옵니다. |
IsAlive |
현재 스레드의 실행 상태를 나타내는 값을 가져옵니다. |
IsBackground |
스레드가 배경 스레드인지를 나타내는 값을 가져오거나 설정합니다. |
IsThreadPoolThread |
스레드가 관리되는 스레드 풀에 속하는지를 나타내는 값을 가져옵니다. |
ManagedThreadId |
현재 관리되는 스레드의 고유 식별자를 가져옵니다. |
Name |
스레드의 이름을 가져오거나 설정합니다. |
Priority |
스레드의 예약 우선 순위를 나타내는 값을 가져오거나 설정합니다. |
ThreadState |
현재 스레드의 상태를 포함하는 값을 가져옵니다. |
메서드
Abort() |
사용되지 않습니다.
이 메서드가 호출되는 스레드에서 ThreadAbortException을 발생시켜 스레드 종료 프로세스를 시작합니다. 이 메서드를 호출하면 대개 스레드가 종료됩니다. |
Abort(Object) |
사용되지 않습니다.
이 메서드가 호출되는 스레드에서 ThreadAbortException을 발생시켜 스레드 종료 프로세스를 시작하고, 스레드 종료에 대한 예외 정보를 제공합니다. 이 메서드를 호출하면 대개 스레드가 종료됩니다. |
AllocateDataSlot() |
모든 스레드에 명명되지 않은 데이터 슬롯을 할당합니다. 성능을 향상시키려면 ThreadStaticAttribute 특성으로 표시된 필드를 대신 사용합니다. |
AllocateNamedDataSlot(String) |
모든 스레드에 명명된 데이터 슬롯을 할당합니다. 성능을 향상시키려면 ThreadStaticAttribute 특성으로 표시된 필드를 대신 사용합니다. |
BeginCriticalRegion() |
스레드 중단 또는 처리되지 않은 예외로 인해 애플리케이션 도메인의 다른 작업이 손상될 수 있는 코드 영역이 실행될 수 있다는 사실을 호스트에 알립니다. |
BeginThreadAffinity() |
관리되는 코드가 현재 실제 운영 체제 스레드의 ID에 종속되는 명령을 실행하려고 한다는 사실을 호스트에 알립니다. |
DisableComObjectEagerCleanup() |
현재 스레드에 대해 RCW(런타임 호출 가능 래퍼)의 자동 정리를 해제합니다. |
EndCriticalRegion() |
스레드 중단 또는 처리되지 않은 예외가 현재 작업에만 영향을 주는 코드 영역이 실행될 것임을 호스트에 알립니다. |
EndThreadAffinity() |
관리되는 코드가 현재 실제 운영 체제 스레드의 ID에 종속되는 명령의 실행을 완료했음을 호스트에 알립니다. |
Equals(Object) |
지정된 개체가 현재 개체와 같은지 확인합니다. (다음에서 상속됨 Object) |
Finalize() |
가비지 컬렉션기에서 Thread 개체를 회수할 때 리소스가 해제되고 다른 정리 작업이 수행되도록 합니다. |
FreeNamedDataSlot(String) |
프로세스의 모든 스레드에 대해 이름과 슬롯 간의 연관을 없앱니다. 성능을 향상시키려면 ThreadStaticAttribute 특성으로 표시된 필드를 대신 사용합니다. |
GetApartmentState() |
아파트 상태를 나타내는 ApartmentState 값을 반환합니다. |
GetCompressedStack() |
사용되지 않습니다.
사용되지 않습니다.
현재 스레드 스택을 캡처하는 데 사용할 수 있는 CompressedStack 개체를 반환합니다. |
GetCurrentProcessorId() |
현재 스레드가 실행 중인 프로세서를 나타내는 데 사용되는 ID를 가져옵니다. |
GetData(LocalDataStoreSlot) |
현재 스레드의 도메인 내에서 현재 스레드의 지정된 슬롯에서 값을 검색합니다. 성능을 향상시키려면 ThreadStaticAttribute 특성으로 표시된 필드를 대신 사용합니다. |
GetDomain() |
현재 스레드가 실행 중인 현재 도메인을 반환합니다. |
GetDomainID() |
고유한 애플리케이션 도메인 식별자를 반환합니다. |
GetHashCode() |
현재 스레드의 해시 코드를 반환합니다. |
GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
GetNamedDataSlot(String) |
명명된 데이터 슬롯을 찾습니다. 성능을 향상시키려면 ThreadStaticAttribute 특성으로 표시된 필드를 대신 사용합니다. |
GetType() |
현재 인스턴스의 Type을 가져옵니다. (다음에서 상속됨 Object) |
Interrupt() |
WaitSleepJoin 스레드 상태에 있는 스레드를 중단합니다. |
Join() |
표준 COM 및 |
Join(Int32) |
표준 COM 및 SendMessage 펌프를 계속 수행하면서 이 인스턴스가 나타내는 스레드가 종료되거나 지정된 시간이 경과할 때까지 호출 스레드를 차단합니다. |
Join(TimeSpan) |
표준 COM 및 SendMessage 펌프를 계속 수행하면서 이 인스턴스가 나타내는 스레드가 종료되거나 지정된 시간이 경과할 때까지 호출 스레드를 차단합니다. |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
MemoryBarrier() |
다음과 같이 메모리 액세스를 동기화합니다. 현재 스레드를 실행 중인 프로세서는 MemoryBarrier()에 대한 호출 이전의 메모리 액세스가 MemoryBarrier()에 대한 호출 이후의 메모리 액세스 뒤에 실행되는 방식으로 명령을 다시 정렬할 수 없습니다. |
ResetAbort() |
사용되지 않습니다.
현재 스레드에 대해 요청된 Abort(Object)를 취소합니다. |
Resume() |
사용되지 않습니다.
사용되지 않습니다.
사용되지 않습니다.
일시 중단된 스레드를 다시 시작합니다. |
SetApartmentState(ApartmentState) |
스레드를 시작하기 전에 스레드의 아파트 상태를 설정합니다. |
SetCompressedStack(CompressedStack) |
사용되지 않습니다.
사용되지 않습니다.
캡처한 CompressedStack을 현재 스레드에 적용합니다. |
SetData(LocalDataStoreSlot, Object) |
해당 스레드의 현재 도메인에 대해 현재 실행 중인 스레드의 지정된 슬롯에서 데이터를 설정합니다. 성능을 향상시키려면 ThreadStaticAttribute 특성으로 표시된 필드를 대신 사용합니다. |
Sleep(Int32) |
지정된 시간(밀리초) 동안 현재 스레드를 일시 중단합니다. |
Sleep(TimeSpan) |
지정된 시간 동안 현재 스레드를 일시 중단합니다. |
SpinWait(Int32) |
스레드가 |
Start() |
운영 체제에서 현재 인스턴스의 상태를 Running으로 변경하도록 합니다. |
Start(Object) |
운영 체제에서 현재 인스턴스의 상태를 Running으로 변경하도록 하며 경우에 따라 스레드가 실행하는 메서드에 사용될 데이터가 포함된 개체를 제공합니다. |
Suspend() |
사용되지 않습니다.
사용되지 않습니다.
사용되지 않습니다.
스레드를 일시 중단하며 스레드가 이미 일시 중단된 경우에는 아무런 효과도 나타나지 않습니다. |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
TrySetApartmentState(ApartmentState) |
스레드를 시작하기 전에 스레드의 아파트 상태를 설정합니다. |
UnsafeStart() |
운영 체제에서 현재 인스턴스의 상태를 Running으로 변경하도록 합니다. |
UnsafeStart(Object) |
운영 체제에서 현재 인스턴스의 상태를 Running으로 변경하도록 하며 경우에 따라 스레드가 실행하는 메서드에 사용될 데이터가 포함된 개체를 제공합니다. |
VolatileRead(Byte) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(Double) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(Int16) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(Int32) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(Int64) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(IntPtr) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(Object) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(SByte) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(Single) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(UInt16) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(UInt32) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(UInt64) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileRead(UIntPtr) |
필드의 값을 읽습니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 뒤에 나타나는 경우 프로세서가 이 메서드 앞으로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(Byte, Byte) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(Double, Double) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(Int16, Int16) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(Int32, Int32) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(Int64, Int64) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(IntPtr, IntPtr) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(Object, Object) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(SByte, SByte) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(Single, Single) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(UInt16, UInt16) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(UInt32, UInt32) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(UInt64, UInt64) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
VolatileWrite(UIntPtr, UIntPtr) |
필드에 값을 씁니다. 필요한 시스템에서는 프로세서가 메모리 작업을 다시 정렬하는 것을 막는 메모리 차단을 다음과 같이 삽입합니다. 코드에서 읽기 또는 쓰기가 이 메서드 앞에 나타나는 경우 프로세서가 이 메서드 뒤로 읽기 또는 쓰기를 이동할 수 없습니다. |
Yield() |
호출 스레드가 현재 프로세서에서 실행할 준비가 되어 있는 다른 스레드에 실행 명령을 내리도록 합니다. 운영 체제에서 실행 명령을 내릴 스레드를 선택합니다. |
명시적 인터페이스 구현
_Thread.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다. |
_Thread.GetTypeInfo(UInt32, UInt32, IntPtr) |
인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다. |
_Thread.GetTypeInfoCount(UInt32) |
개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1). |
_Thread.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다. |
적용 대상
스레드 보안
이 형식은 스레드로부터 안전합니다.