Supplement: for example: (IntI =0I <10I ++)
{
Thread t =NewThread () T. Start ()
}
This is not a thread with the same name
Thread t = new thread ();
In each loop, the T variable in the previous loop has expired. This is a problem with the variable scope. Please refer to this document.
C # allows the same name, but the two variables have different scopes, such:
Class { Private String Name; // Name1, class member name (global variable) Public A ( String Name) // Name2, method parameters { This . Name = Name; name1 name2} Public Void B (){ String Name = " Love " ; This . Name = Name; // Class member local variables }}
You can manage threads with the same name, such as placing an array:
Thread threads [] = new thread [10];
For (INT I = 0 I <10 I ++ ){
Threads [I] = new thread ()
Threads [I]. Start ();
}
A thread is the smallest executable unit. In your example, the thread executes every loop. So there is nothing that cannot be executed with the same name. You should first understand what a thread is.