using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
public class SimpleThread
{
public delegate void Start(object o);
private class Args
{
public object o;
public Start s;
public void work() { s(o); }
}
public static Thread CreateThread(Start s, Object arg)
{
Args a = new Args();
a.o = arg;
a.s = s;
Thread t = new Thread(new ThreadStart(a.work));
return t;
}
class Worker
{
public static void WorkerMethod(object o)
{
Console.WriteLine("WorkerMethod:"+o);
}
}
public class Work
{
public static void Main()
{
Thread t = SimpleThread.CreateThread(new SimpleThread.Start(Worker.WorkerMethod),51);
t.Start();
t.Join(Timeout.Infinite);
}
}
}
//线程调用有参函数->自定义线程->无参函数->内部可以得到参数及有参函数指针->结构体实现