📄 module1.vb
字号:
Imports System
Imports System.Threading
' 此用命名空间System.Threading,以得到类Thread,因为类Thread中定义了处理线 '程的属性和方法
Module Module1
' 以下是创建了一个自己的类NonMainClass,并创建了三个方法:TestMethod1、
' TestMethod2和TestMethod13,并且这三个方法功能相似,通过循环向输出设备输出
' 与自己调用方法有关的信息。
Public Class NonMainClass
Public Sub TestMethod1()
Dim i As Integer
i = 0
While (i < 10)
Console.WriteLine("这显示的是类NonMainClass中的方法_TestMethod1的内容", i)
i += 1
End While
End Sub
Public Sub TestMethod2()
Dim i As Integer
i = 0
While (i < 10)
Console.WriteLine("这显示的是类NonMainClass中的方法_TestMethod2的内容", i)
i += 1
End While
End Sub
Public Sub TestMethod3()
Dim i As Integer
i = 0
While (i < 10)
Console.WriteLine("这显示的是类NonMainClass中的方法_TestMethod3的内容", i)
i += 1
End While
End Sub
End Class
Public Class ThreadTest
' 定义了另一个类ThreadTest并使用上面创建的类NonMainClass
Public Shared Sub Main()
Dim TestClass As New NonMainClass
Dim TestThread1, TestThread2, TestThread3 As Thread
' 创建了类Thread的实例
TestThread1= New Thread(New ThreadStart(AddressOf TestClass.TestMethod1))
TestThread1.Start() ' 通过线程的Start()方法,来调用线程
TestThread2= New Thread(New ThreadStart(AddressOf TestClass.TestMethod2))
TestThread2.Start()
TestThread3= New Thread(New ThreadStart(AddressOf TestClass.TestMethod3))
TestThread3.Start()
Dim i As Integer
i = 0
While (i < 10)
Console.WriteLine("这显示的是类ThreadTest中的方法Main中的内容", i)
i += 1
End While
End Sub
End Class
End Module
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -