Imports System.Threading Imports System Public Class Form1 Dim th1, th2 As Thread Public Sub Method1() Dim i As Integer For i = 1 To 100 If Me.Label1.BackColor = Color.DarkRed Then Me.Label1.BackColor = Color.Gold End If System.Threading.Thread.Sleep(100) If Me.Label1.BackColor = Color.Gold Then Me.Label1.BackColor = Color.DarkRed End If System.Threading.Thread.Sleep(100) Next End Sub Public Sub Method2() Dim i As Integer For i = 1 To 100 If Me.Label2.BackColor = Color.DarkRed Then Me.Label2.BackColor = Color.Gold End If System.Threading.Thread.Sleep(500) If Me.Label2.BackColor = Color.Gold Then Me.Label2.BackColor = Color.DarkRed End If System.Threading.Thread.Sleep(500) Next End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.Label1.BackColor = Color.DarkRed Me.Label2.BackColor = Color.DarkRed th1 = New Thread(New ThreadStart(AddressOf Method1)) th1.Start() th2 = New Thread(New ThreadStart(AddressOf Method2)) th2.Start() System.Threading.Thread.Sleep(1000) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.FormClosed th1.Abort() ' 調用此方法一般會終止線程。 th2.Abort() End Sub End Class