说我有这个代码:
public int A = 0;
//This is the method that will
//be run as a thread
public void Thread1()
{
public bool continue = true;
while (continue == true)
{
if (A==2)
{
Thread t2 = new Thread(new ThreadStart(Thread2));
}
//Some other code here
}
}
//This is the method that Thread1
//will try to run if A = 2
public void Thread2()
{
//Coding in this thread
}
假设 int A 通过其他方法或类似方法设置为 2。thread1 是否能够从自身内部创建新的 thread2?我觉得我会问,因为我有一个习惯,当我尝试做一些我不完全理解的事情时,我会搞砸我的代码。