文章目录
vb.net并行计算
关键区域
Thread.BeginCriticalRegion 通知宿主执行将要进入一个代码区域,在该代码区域内线程中止或未经处理的异常的影响可能会危害应用程序域中的其他任务。
关键区域是指线程中止或未经处理的异常的影响可能不限于当前任务的区域。 相反,非关键代码区域中的中止或失败只对出现错误的任务有影响。
我们将减法部分与输出计算结果部分纳入关键区域
Vb.net代码 收藏代码
Imports System
Imports System.Threading
Imports System.Diagnostics
Imports System.Diagnostics.ThreadState
Module Module1
Sub Main()
Dim mythread1 As Thread
Dim mythread2 As Thread
Dim mythread3 As Thread
'创建线程对象
mythread1 = New Thread(AddressOf mythreadrun)
mythread2 = New Thread(AddressOf mythreadrun)
mythread3 = New Thread(AddressOf mythreadrun)
订阅专栏 解锁全文
1158

被折叠的 条评论
为什么被折叠?



