• C# 线程


    using System;
    using System.Threading;

    namespace ConsoleApplication1
    {
        //class Program
        //{
        //    static void Main(string[] args)
        //    {
        //        Thread DepthChangedThread = new Thread(delegate() { Console.WriteLine("OK"); });
        //        DepthChangedThread.Name = "OK";
        //        Console.WriteLine(DepthChangedThread.Priority.ToString());
        //        DepthChangedThread.Abort();
        //        DepthChangedThread.Join();
        //        DepthChangedThread.Start();
        //    }
        //}

        class MainRun
        {

            static int interval = 700;
            static void Main()
            {
                Console.WriteLine("Interal to display results at?");
                interval = int.Parse(Console.ReadLine());

                Thread thisThread = Thread.CurrentThread;
                thisThread.Name = "Main Thread";

                //ThreadStart workerStart = new ThreadStart(StartMethod);
                Thread workerThread = new Thread(delegate() { StartMethod(); });
                workerThread.Name = "Worker";
                workerThread.Start();

                DisplayNumberThread();
                Console.WriteLine("Main Thread Finished!");

                Console.ReadLine();        
            }
            static void DisplayNumberThread()
            {
                Thread thisThead = Thread.CurrentThread;
                string name = thisThead.Name;
                Console.WriteLine("Startint thread:"+name);
                Console.WriteLine(name+":Current culture="+thisThead.CurrentCulture);
                //int interval=700;
                for (double i =1; i <=9*interval; i++)
                {
                    if(i%interval==0)
                        Console.WriteLine(name+":count has reahed."+i);
                   
                }
            }
            static void StartMethod()
            {
                DisplayNumberThread();
                Console.WriteLine("Worker Thread Finished!");
            }
        }
       
    } //输入一个数后,显示出这个数的几个倍数。注意里面的ThreadStart 那,如果不用这个可以使用匿名委托。Culture是区域的意思。

  • 相关阅读:
    echarts 柱状图
    echarts 双y轴渐变色进度条
    echarts 折线图
    算法系列一:本质以及特征
    导致薪水低的九大行为表现
    Tomcat使用shutdown.sh无法关闭
    定时将上月的数据导入到Oracle中,并更新指定的列
    定时抛转数据 crontab
    微服务主要模块
    tk.mybatis 调用oracle,生成ID
  • 原文地址:https://www.cnblogs.com/fat_li/p/1837467.html
Copyright © 2020-2023  润新知