<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FThread%2FThreadStatic</id>
		<title>VB.Net Tutorial/Thread/ThreadStatic - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FThread%2FThreadStatic"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Thread/ThreadStatic&amp;action=history"/>
		<updated>2026-04-05T07:21:57Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Thread/ThreadStatic&amp;diff=3596&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Thread/ThreadStatic&amp;diff=3596&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:30Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Thread/ThreadStatic&amp;diff=3597&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Thread/ThreadStatic&amp;diff=3597&amp;oldid=prev"/>
				<updated>2010-05-26T12:56:06Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==ThreadStatic==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Threading&lt;br /&gt;
public class Test&lt;br /&gt;
   Shared Dim obj As MyClass1 = new MyClass1&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
               Dim thread1 As New Thread(AddressOf doSomething)&lt;br /&gt;
               Dim thread2 As New Thread(AddressOf doSomething)&lt;br /&gt;
               Dim thread3 As New Thread(AddressOf doSomething)&lt;br /&gt;
               thread1.Start()&lt;br /&gt;
               thread2.Start()&lt;br /&gt;
               thread3.Start()&lt;br /&gt;
   End Sub&lt;br /&gt;
   &lt;br /&gt;
   Private Shared Sub doSomething()&lt;br /&gt;
           Dim i As Integer&lt;br /&gt;
           For i = 1 To 3&lt;br /&gt;
               obj.SharedData = i&lt;br /&gt;
               obj.threadUniqueID = AppDomain.GetCurrentThreadId()&lt;br /&gt;
               Console.WriteLine(&amp;quot;ID: &amp;quot; &amp;amp; obj.threadUniqueID &amp;amp; &amp;quot;, I:=&amp;quot; &amp;amp; i &amp;amp; &amp;quot;, SharedData: &amp;quot; &amp;amp; obj.SharedData.ToString())&lt;br /&gt;
               Thread.CurrentThread.Sleep(250)&lt;br /&gt;
           Next&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class MyClass1&lt;br /&gt;
       &amp;lt;ThreadStatic()&amp;gt; Public threadUniqueID As Integer&lt;br /&gt;
       Public SharedData As Integer = 0&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;ID: 2564, I:=1, SharedData: 1&lt;br /&gt;
ID: 3196, I:=1, SharedData: 1&lt;br /&gt;
ID: 2656, I:=1, SharedData: 1&lt;br /&gt;
ID: 2564, I:=2, SharedData: 2&lt;br /&gt;
ID: 3196, I:=2, SharedData: 2&lt;br /&gt;
ID: 2656, I:=2, SharedData: 2&lt;br /&gt;
ID: 2564, I:=3, SharedData: 3&lt;br /&gt;
ID: 3196, I:=3, SharedData: 3&lt;br /&gt;
ID: 2656, I:=3, SharedData: 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==ThreadStatic field==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Threading&lt;br /&gt;
Public Class SharedByThread&lt;br /&gt;
   &amp;lt;ThreadStatic&amp;gt; Private Shared Count As Integer&lt;br /&gt;
   Public Shared Sub Main()&lt;br /&gt;
   &lt;br /&gt;
      Dim secondThread As New thread(AddressOf Thread2Proc)&lt;br /&gt;
      secondThread.Start()&lt;br /&gt;
      count = 100&lt;br /&gt;
      For ctr As Integer = 0 to 10&lt;br /&gt;
         Console.WriteLine(&amp;quot;The value of count in the main thread is {0}.&amp;quot;, count)&lt;br /&gt;
         IncrementCounter(200)&lt;br /&gt;
      Next&lt;br /&gt;
   End Sub&lt;br /&gt;
   Public Shared Sub Thread2Proc()&lt;br /&gt;
      count = 0&lt;br /&gt;
      For ctr As Integer = 0 to 10&lt;br /&gt;
         Console.WriteLine(&amp;quot;The value of count in the second thread is {0}.&amp;quot;, count)&lt;br /&gt;
         IncrementCounter(250)&lt;br /&gt;
      Next&lt;br /&gt;
   End Sub&lt;br /&gt;
   Public Shared Sub IncrementCounter(delay As Integer)&lt;br /&gt;
      count +=1&lt;br /&gt;
      Thread.Sleep(delay)&lt;br /&gt;
   End Sub&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The value of count in the second thread is 0.&lt;br /&gt;
The value of count in the main thread is 100.&lt;br /&gt;
The value of count in the main thread is 101.&lt;br /&gt;
The value of count in the second thread is 1.&lt;br /&gt;
The value of count in the main thread is 102.&lt;br /&gt;
The value of count in the second thread is 2.&lt;br /&gt;
The value of count in the main thread is 103.&lt;br /&gt;
The value of count in the second thread is 3.&lt;br /&gt;
The value of count in the main thread is 104.&lt;br /&gt;
The value of count in the second thread is 4.&lt;br /&gt;
The value of count in the main thread is 105.&lt;br /&gt;
The value of count in the main thread is 106.&lt;br /&gt;
The value of count in the second thread is 5.&lt;br /&gt;
The value of count in the main thread is 107.&lt;br /&gt;
The value of count in the second thread is 6.&lt;br /&gt;
The value of count in the main thread is 108.&lt;br /&gt;
The value of count in the second thread is 7.&lt;br /&gt;
The value of count in the main thread is 109.&lt;br /&gt;
The value of count in the second thread is 8.&lt;br /&gt;
The value of count in the main thread is 110.&lt;br /&gt;
The value of count in the second thread is 9.&lt;br /&gt;
The value of count in the second thread is 10.&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>