using System.Threading;
// 初始化 Thread 类的新实例。 // < param name="start">无参委托对象.</ param> public Thread(ThreadStart start)
void Start()
{
//创建无参线程对象
Thread thr = new Thread(Func_NoArguments);
//启动线程
thr.Start();
}
// Function Of No Arguments.
void Func_NoArguments()
{
Debug.Log("Run Func_NoArguments");
}
// 初始化 Thread 类的新实例。 // < param name="start">有参委托对象.< /param> public Thread(ParameterizedThreadStart start)
void Start()
{
//创建有参线程对象
Thread thr = new Thread(Func_Arguments);
//启动线程,传入参数
thr.Start("Lanou");
}
// Function Of Have Arguments.
void Func_Arguments(object data)
{
Debug.Log("Run Func_Arguments, Data = " + data);
}
// 初始化 Thread 类的新实例。 // < param name="start">无参委托对象.< /param> // < param name="maxStackSize">使用的最大堆栈大小.< /param> public Thread(ThreadStart start,int maxStackSize)
void Start()
{
//创建无参线程对象,限制256KB堆栈大小
Thread thr = new Thread(Func_NoArguments,262144);
//启动线程
thr.Start();
}
// Function Of No Arguments.
void Func_NoArguments()
{
Debug.Log("Run Func_NoArguments");
}
// 初始化 Thread 类的新实例。 // < param name="start">有参委托对象.< /param> // < param name="maxStackSize">使用的最大堆栈大小.< /param> public Thread(ParameterizedThreadStart start,int maxStackSize)
void Start()
{
//创建有参线程对象,限制256KB堆栈大小
Thread thr = new Thread(Func_Arguments,262144);
//启动线程,传入参数
thr.Start("Lanou");
}
// Function Of Have Arguments.
void Func_Arguments(object data)
{
Debug.Log("Run Func_Arguments, Data = " + data);
}
void Start()
{
//创建无参线程对象
Thread thr = new Thread(Func_NoArguments);
//启动线程
thr.Start();
}
// Function Of No Arguments.
void Func_NoArguments()
{
Debug.Log("Run Func_NoArguments");
}
void Start()
{
//创建有参线程对象
Thread thr = new Thread(Func_Arguments);
//启动线程,传入参数
thr.Start("Lanou");
}
// Function Of Have Arguments.
void Func_Arguments(object data)
{
Debug.Log("Run Func_Arguments, Data = " + data);
}
// Unlike "StartMultithreadedWorkloadExecution", you will have to build your own IThreadWorkerObject.
// Downside: It requires some extra work. Upside: you got more controll over what goes in and comes out
// Infact: You can create you own polymorphed IThreadWorkerObject-array, each ellement being a completely different type. For example: the statemachines of enemies are IThreadWorkerObject's and the array contains completely different classes with enemies/AI-behaviours.
// < param name="workerObjects">An array of IThreadWorkerObject objects to be handled by the threads. If you want multiple cores/threads to be active, make sure that the number of IThreadWorkerObject's proves matches/exeeds your preferred number maxWorkingThreads. < /param>
// < param name="onComplete">Fired when all re-packaged workLoad-objects are finished computing< /param>
// < param name="onPackageExecuted">Fires foreach finished re-packaged set of workLoad-object< /param>
// < param name="maxThreads"> Lets you choose how many threads will be run simultaneously by the threadpool. Default: -1 == number of cores minus one, to make sure the MainThread has at least one core to run on. (quadcore == 1 core Mainthread, 3 cores used by the ThreadPoolScheduler)< /param>
// < param name="scheduler">If Null, a new ThreadPoolScheduler will be instantiated.< /param>
// < param name="safeMode">Executes all the computations within try-catch events, logging it the message + stacktrace< /param>
// < returns>A ThreadPoolScheduler that handles all the repackaged workLoad-Objects< /returns>
public static ThreadPoolScheduler StartMultithreadedWorkerObjects(IThreadWorkerObject[] workerObjects, ThreadPoolSchedulerEvent onCompleteCallBack, ThreadedWorkCompleteEvent onPackageExecuted = null, int maxThreads = -1, ThreadPoolScheduler scheduler = null, bool safeMode = true)
{
if (scheduler == null)
scheduler = CreateThreadPoolScheduler();
scheduler.StartASyncThreads(workerObjects, onCompleteCallBack, onPackageExecuted, maxThreads, safeMode);
return scheduler;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有