• 多线程03-Abort


        class Program
        {
            static void Main()
            {
                Console.WriteLine("Main Thread State={0}", Thread.CurrentThread.ThreadState.ToString());
                Thread t = new Thread(ShowMessage);
                Console.WriteLine("子 Thread State={0}", t.ThreadState.ToString());
                t.Start();
                Console.WriteLine("子 Thread State={0}", t.ThreadState.ToString());
                //干掉子线程[等执行Abort期间,人家都执行完了...白等了,散伙吧...]
                Thread.Sleep(2000);
                t.Abort();
                Console.WriteLine("子 Thread State={0}", t.ThreadState.ToString());
                for (var i = 0; i < 10; i++)
                {
                    Console.WriteLine(i);
                }
                Console.ReadKey();
            }
            static void ShowMessage()
            {
                for (var i = 0; i < 10; i++)
                {
                    Thread.Sleep(10);
                    Console.WriteLine(i);
                }
            }
        }
  • 相关阅读:
    c++ 优化的动态数组 Vector
    C++ 重载赋值运算符
    k8s中引入外部服务
    MySQL----mysql_secure_installation 安全配置向导
    elk参考连接
    限制不同的用户操作k8s的资源
    tcpdump 抓包命令使用教程
    日志管理——rsyslog、logrotate
    lsyncd配置文件详细说明
    Systemd 服务配置文件(转载)
  • 原文地址:https://www.cnblogs.com/shidengyun/p/5599934.html
Copyright © 2020-2023  润新知