public class threadclass
我們提供的服務有:網站設計、成都網站設計、微信公眾號開發(fā)、網站優(yōu)化、網站認證、雄縣ssl等。為上千企事業(yè)單位解決了網站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的雄縣網站制作公司
{
public int a;
public void threadmethod()
{
//use a;
}
}
...
threadclass tc = new ....
tc.a = 10;
Thread t = new ThreadStart(tc.threadmethod);
t.Start
Sub?Main()
Dim?thr?As?New?Thread(AddressOf?循環(huán))
thr.Start("a")
End?Sub
Sub?循環(huán)(a()?As?String)
'這里隨你干什么循環(huán)也行
For?Each?i?As?String?In?a
MsgBox(i)
Next
End?Sub
看懂了吧 參數只能有一個 也可以不是數組,在a() As String的a后面去掉括號就行
Public?Class?Form1
Public?Class?SquareClass?'把多線程調用的函數封裝到類中,通過類事件返回
Public?Value?As?Double
Public?Square?As?Double
Public?Event?ThreadComplete(ByVal?Square?As?Double)
Public?Sub?CalcSquare()
Square?=?Value?*?Value
RaiseEvent?ThreadComplete(Square)
End?Sub
End?Class
Dim?WithEvents?oSquare?As?SquareClass
Private?Sub?Button1_Click(sender?As?Object,?e?As?EventArgs)?Handles?Button1.Click?'多線程返回值測試,當線程運行完成激發(fā)事件
oSquare?=?New?SquareClass()
Dim?t?As?New?Threading.Thread(AddressOf?oSquare.CalcSquare)
oSquare.Value?=?30
t.Start()
End?Sub
Sub?SquareEventHandler(ByVal?Square?As?Double)?Handles?oSquare.ThreadComplete?'響應事件函數
MsgBox("The?square?is?"??Square)
End?Sub
End?Class