本文实例讲述了c#线程池操作方法。分享给大家供大家参考。具体如下:
static void main(string[] args) { //设置线程池中的线程数最大为1000, //第一个为工作者线程,第二个为i/o线程 threadpool.setmaxthreads(1000, 1000); for (int i = 0; i < 10;i ) { threadpool.queueuserworkitem(new waitcallback(showmessage), string.format("当前编号{0}",i)); } console.readline(); } //带参数 无返回值 static void showmessage(object x) { string current = string.format("当前线程id为{0}", system. threading.thread.currentthread.managedthreadid); //等待1秒钟 system.threading.thread.sleep(1000); console.writeline(string.format("{0},输入为{1}", current, x)); }
希望本文所述对大家的c#程序设计有所帮助。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论