16,554
社区成员
发帖
与我相关
我的任务
分享
Imports System.Threading
Module Module1
Public Times As Int32
Sub Main()
Times = 3
Dim f1 As New test
Dim th1 As New Thread(AddressOf f1.Task)
th1.Start()
Times = 5
Dim f2 As New test
Dim th2 As New Thread(AddressOf f2.Task)
th2.Start()
Thread.Sleep(1000)
End Sub
Public Class test
Public Sub Task()
Dim v As Int32
For i As Int32 = 1 To Times
v += i
Next
Console.WriteLine(v)
End Sub
End Class
End Module
Sub Main()
Times = 3
Dim f1 As New test
Dim th1 As New Thread(AddressOf f1.Task)
th1.Start()
For i As Integer = 0 To 10000000
Next
Times = 5
Dim f2 As New test
Dim th2 As New Thread(AddressOf f2.Task)
th2.Start()
Thread.Sleep(1000)
End Sub