zoukankan      html  css  js  c++  java
  • 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是区域的意思。

  • 相关阅读:
    第10天, BFC, IE浏览器常见兼容问题, css Hack, 图片优化, 项目测试检查
    day08,iconfont的使用,精灵技术,css小箭头制作
    day7,vertical-align,显示与隐藏 ,圆角 边框,透明度及兼容,ps常用工具,项目规范,icon怎么用
    五大浏览器以及内核
    块状元素和行内元素的区别
    LESS使用指南
    用grunt搭建自动化的web前端开发环境
    grunt前端打包--css篇
    SASS用法指南
    Angular Prerender SEO实践
  • 原文地址:https://www.cnblogs.com/fat_li/p/1837467.html
Copyright © 2011-2022 走看看