这个应该很容易啊public class myClass { private int SleepTime; public myClass(int sleepTime) { this.SleepTime = sleepTime; } public DoSomething() { //do some thing Sleep(this.SleepTime); }
}启动部分 static Main() { myClass first = new myClass(1000); Thread thread1 = new Thread(new ThreadStart(first.DoSomething)); myClass second = new myClass(50); Thread thread2 = new Thread(new ThreadStart(second.DoSomething)); thread1.Start(); thread2.Start(); }
{
//do something
Sleep(SleepTime);}
{
doSomething(100);
}thread2()
{
doSomething(200);
}
{
private int SleepTime;
public myClass(int sleepTime)
{
this.SleepTime = sleepTime;
}
public DoSomething()
{
//do some thing
Sleep(this.SleepTime);
}
}启动部分
static Main()
{
myClass first = new myClass(1000);
Thread thread1 = new Thread(new ThreadStart(first.DoSomething));
myClass second = new myClass(50);
Thread thread2 = new Thread(new ThreadStart(second.DoSomething)); thread1.Start();
thread2.Start();
}
http://www.yesky.com/SoftChannel/72342380468109312/20030516/1701196.shtml