zoukankan      html  css  js  c++  java
  • c# 多线程

    1. using System;   
    2. using System.Collections.Generic;   
    3. using System.Text;   
    4. using System.Threading;   
    5. namespace 线程练习   
    6. {   
    7.     class Program   
    8.     {   
    9.         static void Main(string[] args)   
    10.         {   
    11.             Console.WriteLine("开始一个新的线程,名为次线程");   
    12.             Thread t = new Thread(new ThreadStart(ThreadProc));   
    13.             t.Start();   
    14.             for (int i = 0; i < 4; i++)   
    15.             {   
    16.                 Console.WriteLine("主线程:" + i);   
    17.                 Thread.Sleep(1000);   
    18.             }   
    19.             Console.WriteLine("调用Join函数等待次线程结束");   
    20.             //当次线程执行完毕后,Join阻塞调用线程,直到某个线程终止为止,本例为次线程   
    21.             t.Join();   
    22.             Console.WriteLine("线程执行完毕");   
    23.         }   
    24.         public static void ThreadProc()   
    25.         {   
    26.             for (int i = 0; i < 10; i++)   
    27.             {   
    28.                 Console.WriteLine("ThreadPorc:{0}", i);   
    29.                 Thread.Sleep(1000);//将当前进程阻塞指定的毫秒数   
    30.             }   
    31.   
    32.   
    33.         }   
    34.     }   
    35. }  
  • 相关阅读:
    Spark面对OOM问题的解决方法及优化总结 (转载)
    spark rdd 宽窄依赖理解
    hive orc update
    hive sql 语句执行顺序及执行计划
    java 正则 贪婪匹配 匹配sql语句中的引号内容
    java 权重随机算法实现
    MySQL创建用户和加限权
    MySQL完整性约束
    MySQL基础操作与数据类型
    MySQL数据库初识
  • 原文地址:https://www.cnblogs.com/hsapphire/p/1978524.html
Copyright © 2011-2022 走看看