using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;namespace AutoResetEvent1
{
class Program
{
static void Main(string[] args)
{
}
} class Test
{
const int nNum = 100;
static AutoResetEvent event_buy = new AutoResetEvent(false);
static AutoResetEvent event_pay = new AutoResetEvent(false); //Thread_Proc proc=new Thread_Proc();
//创建两个线程
Thread thread_buy = new Thread(new ThreadStart(Thread_Proc.BuyBook));
thread_buy.Name ="Buy";//这里报错,提示“类、结构或接口成员声明中的标记“=”无效”
Thread thread_pay = new Thread(new ThreadStart(Thread_Proc.PayMoney));
} class Thread_Proc
{
static public void PayMoney()
{} static public void BuyBook()
{}
}
}
为什么给线程取名会报这种错误啊
using System.Collections.Generic;
using System.Text;
using System.Threading;namespace AutoResetEvent1
{
class Program
{
static AutoResetEvent event_buy = new AutoResetEvent(false);
static AutoResetEvent event_pay = new AutoResetEvent(false);
const int nNum = 100;
static void Main(string[] args)
{
//Thread_Proc proc=new Thread_Proc();
//创建两个线程
Thread thread_buy = new Thread(new ThreadStart(Thread_Proc.BuyBook));
thread_buy.Name ="Buy";
thread_buy.Start(); }
} class Thread_Proc
{
static public void PayMoney()
{ } static public void BuyBook()
{ }
}
}好奇怪啊
public void CreateThread()
{
Thread thread_buy = new Thread(new ThreadStart(Thread_Proc.BuyBook));
thread_buy.Name = "Buy";//这里报错,提示“类、结构或接口成员声明中的标记“=”无效”[/color]
Thread thread_pay = new Thread(new ThreadStart(Thread_Proc.PayMoney));
}