夜的影子
夜的影子2009
全部博文(106)
数据库操作(0)
OOP(4)
操作系统(7)
算法(15)
游戏(1)
文件系统(3)
文章教程(1)
组件(1)
数据库(4)
试题库相关资料(2)
字体效果(1)
图形图像(8)
文件和文件夹(4)
控件类(8)
源代码(28)
2014年(17)
2011年(5)
2010年(75)
2009年(9)
163com
wb123456
ningtaoy
popuping
zsjdingb
xo271225
gocker
ease1000
topper
分类:
2010-04-27 08:06:44
Option Explicit OnOption Strict OnImports SystemImports System.ThreadingPublic Class Test Shared Sub Main() Dim priorityTest As New PriorityTest() Dim threadOne As Thread = New Thread(AddressOf priorityTest.ThreadMethod) threadOne.Name = "ThreadOne" Dim threadTwo As Thread = New Thread(AddressOf priorityTest.ThreadMethod) threadTwo.Name = "ThreadTwo" threadOne.Priority = ThreadPriority.Highest threadTwo.Priority = ThreadPriority.LowestthreadOne.Start() threadTwo.Start() Thread.Sleep(8000) priorityTest.LoopSwitch = False Console.ReadLine() End SubEnd ClassPublic Class PriorityTest Dim loopSwitchValue As Boolean Sub New() loopSwitchValue = True End Sub WriteOnly Property LoopSwitch() As Boolean Set(ByVal value As Boolean) loopSwitchValue = Value End Set End Property Sub ThreadMethod() Dim threadCount As Long = 0 While loopSwitchValue threadCount += 1 End While Console.WriteLine("{0} with {1,11} priority " & _ "has a count = {2,13}", Thread.CurrentThread.Name, _ Thread.CurrentThread.Priority.ToString(), _ threadCount.ToString("N0")) End SubEnd Class'优先级别一共分以下5种 不指定默认为NormalHighest AboveNormal Normal BelowNormal Lowest
上一篇:线程 Thread.实例学习笔记.02
下一篇:剪贴板实例学习笔记.01.
登录 注册