I haven't used multiple threads for a long time. I forget to remember parameterizedthreadstart: Public void start () with the object parameter ()
{
For (INT Index = 0; index <10; index ++)
{
# Region -- prepare parameters --
List <int> List = new list <int> ();
For (INT Param = index; Param <index + 10; Param ++)
{
List. Add (PARAM );
}
# Endregion
Thread thread = new thread (New parameterizedthreadstart (initthreadfunc ));
Thread. Start (list );
}
LogHelper. WriteLine ("Over ");
}
/// <Summary>
/// Executed Function
/// </Summary>
/// <Param name = "list"> </param>
Private void InitThreadFunc (object list)
{
If (list is List <int>)
{
List <int> ll = list as List <int>;
Int result = 0;
Foreach (int n in ll)
{
Result + = n;
}
Loghelper. writeline (result );
}
}
Second:
Initthreadfunc without Parameters
Public void start ()
{
For (INT Index = 0; index <10; index ++)
{
Thread thread = new thread (New threadstart (initthreadfunc ));
Thread. Start ();
}
Loghelper. writeline ("over ");
}
Private void initthreadfunc (){}