다음을 통해 공유


ThreadStaticAttribute 클래스

정적 필드의 값이 각 스레드에 고유함을 나타냅니다.

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<SerializableAttribute> _
<AttributeUsageAttribute(AttributeTargets.Field, Inherited:=False)> _
<ComVisibleAttribute(True)> _
Public Class ThreadStaticAttribute
    Inherits Attribute
‘사용 방법
Dim instance As ThreadStaticAttribute
[SerializableAttribute] 
[AttributeUsageAttribute(AttributeTargets.Field, Inherited=false)] 
[ComVisibleAttribute(true)] 
public class ThreadStaticAttribute : Attribute
[SerializableAttribute] 
[AttributeUsageAttribute(AttributeTargets::Field, Inherited=false)] 
[ComVisibleAttribute(true)] 
public ref class ThreadStaticAttribute : public Attribute
/** @attribute SerializableAttribute() */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Field, Inherited=false) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class ThreadStaticAttribute extends Attribute
SerializableAttribute 
AttributeUsageAttribute(AttributeTargets.Field, Inherited=false) 
ComVisibleAttribute(true) 
public class ThreadStaticAttribute extends Attribute

설명

ThreadStaticAttribute로 표시된 static 필드는 스레드 간에 공유되지 않습니다. 각 실행 스레드에는 필드에 대한 별도의 인스턴스가 있으며 해당 필드에 대한 값을 독립적으로 설정하고 가져옵니다. 필드를 서로 다른 스레드에서 액세스하면 해당 필드에는 다른 값이 들어가게 됩니다.

참고

ThreadStaticAttribute로 표시된 필드의 초기 값을 지정하면 안 됩니다. 이러한 초기화는 클래스 생성자가 실행될 때 한 번만 발생하기 때문에 한 스레드에만 영향을 미칩니다. 초기 값을 지정하지 않으면 필드가 값 형식인 경우 기본값으로 초기화되고 참조 형식인 경우 Null 참조(Visual Basic의 경우 Nothing)로 초기화됩니다.

이 특성을 그대로 사용하고 이 특성에서 파생시키지 마십시오. 다음 예제에서는 ThreadStaticAttribute 구문을 보여 줍니다.

 [ThreadStatic]
 static int value;
 <ThreadStatic> _
 Shared value As Integer

특성 사용에 대한 자세한 내용은 특성을 사용하여 메타데이터 확장을 참조하십시오.

상속 계층 구조

System.Object
   System.Attribute
    System.ThreadStaticAttribute

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

ThreadStaticAttribute 멤버
System 네임스페이스
Attribute 클래스
Thread

기타 리소스

특성을 사용하여 메타데이터 확장
관리되는 스레딩