QueueUserWorkItem_thread.currentthread()

QueueUserWorkItem_thread.currentthread()usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceTestThreadPool{usingSystem.Threading;classProgram{staticvoidMain(string[

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

原文:http://msdn.microsoft.com/zh-cn/library/4yd16hza(VS.80).aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestThreadPool
{
    using System.Threading;

    class Program
    {
        static void Main(string[] args)
        {
            // Queue the task.
            ThreadPool.QueueUserWorkItem(new WaitCallback(dosomething), "jon");
            Console.WriteLine("Main thread does some work, then sleeps.");
            // If you comment out the Sleep, the main thread exits before
            // the thread pool task runs.  The thread pool uses background
            // threads, which do not keep the application running.  (This
            // is a simple example of a race condition.)
            Thread.Sleep(1000);

            Console.WriteLine("Main thread exits.");

            Console.ReadKey();
        }

        // This thread procedure performs the task.
        static void dosomething(object kk)
        {
            Console.WriteLine(string.Format("hellow {0}!", kk));
        }

        //...

    }
}
 ThreadPool.QueueUserWorkItem((kk) =>
            {
                kk = Console.ReadLine();
                Console.WriteLine(string.Format("hellow {0}!", kk));
            });
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/189772.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月8日 下午11:43
下一篇 2026年3月9日 上午7:22


相关推荐

  • numba 高级用法

    numba 高级用法numba是一个用于编译Python数组和数值计算函数的编译器,这个编译器能够大幅提高直接使用Python编写的函数的运算速度。numba使用LLVM编译器架构将纯Python代码生成优化过的机器码,通过一些添加简单的注解,将面向数组和使用大量数学的python代码优化到与c,c++和Fortran类似的性能,而无需改变Python的解释器。Numba的主要特性:动态代码生成(…

    2025年7月13日
    7
  • linux下system函数错误返回-1 错误原因NO child processes

    linux下system函数错误返回-1 错误原因NO child processes调用system函数执行一个shell命令,返回-1,错误提示nochildprocesses但system可以执行成功原因是调用system之前有放置忽略SIGCHLD的语句signal(SIGCHLD,SIG_IGN);如果SIGCHLD信号行为被设置为SIG_IGN时,waitpid()函数有可能因为找不到子进程而报ECHILD错误。似乎我们找到了问题的解决方案:在调用s…

    2022年6月1日
    29
  • Modbus协议解析–小白一看就懂的协议

    Modbus协议解析–小白一看就懂的协议文章目录提问三连 1 什么是 Modbus 2 Modbus 用来干什么 3 Modbus 的内容是什么 提问三连什么是 Modbus Modbus 用来干什么 Modbus 怎么用 1 什么是 Modbus 顾名思义 他是一个 bus 即总线协议 如果你接触到这种协议 相信你所处的行业是工业方面或者你的产品用于工业 Modbus 是一种串行通信协议 是 Modicon 公司 现在的施耐德电气 Schn

    2026年3月19日
    2
  • 统计学的卡方检验方法是什么呢?用几个生活实例带你揭秘!

    统计学的卡方检验方法是什么呢?用几个生活实例带你揭秘!作者|文文酱的数据课堂来源|知乎专栏https://zhuanlan.zhihu.com/p/69888032卡方检验,统计学的方法,现在机器学习看变量的时候也会用到。很多不知道…

    2022年5月13日
    43
  • vue脚手架基本使用[通俗易懂]

    vue脚手架基本使用[通俗易懂]vue脚手架基本使用

    2022年4月22日
    65
  • netstat -an 提示:不是内部或外部命令

    netstat -an 提示:不是内部或外部命令大家都知道 netstat an 可以查看当前网络以及端口 nbsp nbsp 今天在学校机房安装了 phpstudy 像以前一样正常启动 phpstudy 但是却显示 3306 端口被占用 一般我们都会使用 netstat an 命令查看一下本机中是哪一个程序占用了这样一个端口 但是出了一个异常之前没有遇见过的一个异常 当使用 cmd 命令行窗口的时候 输入 netstat an 显示不是内部命令或外部命令 如下图

    2026年3月26日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号