我需要启动一个线程,该线程向 200 个不同的线程发送一个字符串(url)并且它们启动。然后第一个线程停止。当这个 url 返回 404 错误时,所有线程必须停止,第一个线程需要启动。我该如何组织它?谢谢。
对不起我的英语不好。我希望你能理解我)
我如何启动线程:
Thread[] thr;
int good_delete;
static object locker = new object();
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
button2.Enabled = true;
decimal value = numericUpDown1.Value;
int i = 0;
int j = (int)(value);
thr = new Thread[j];
for (; i < j; i++)
{
thr[i] = new Thread(new ThreadStart(go));
thr[i].IsBackground = true;
thr[i].Start();
}
}