06.C#线程Thread
来源:互联网 发布:java string int 转换 编辑:程序博客网 时间:2024/09/21 09:18
Program.cs文件:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;using System.IO;using System.Threading;namespace Test1{ class Program { static void Main(string[] args) { /* 1.使用using System.Threading; 2.自己摸索,可以查看api文档。 */ //1.相当于不带参数的委托delegate Thread t1 = new Thread(new ThreadStart(Test1)); t1.Name = "线程1"; t1.Start(); //2.相当于带参数的委托delegate Thread t2 = new Thread(new ParameterizedThreadStart(Test2)); t2.Name = "线程2"; t2.Priority = ThreadPriority.Highest;//设置线程的优先级(前提是在线程池中) t2.IsBackground = true;//是否在后台执行 t2.Start("lai哈喽"); } static void Test1() { Thread.Sleep(2000);//线程睡眠2秒 Console.WriteLine("当前线程的Name:"+Thread.CurrentThread.Name); } static void Test2(object s1) { Thread.CurrentThread.Join(1000);//线程阻塞1秒 Console.WriteLine(s1+"当前线程的Name:" + Thread.CurrentThread.Name); } }}
1 0
- 06.C#线程Thread
- C# 线程之Thread
- c# 线程化 Thread
- c# Thread 线程
- C#线程问题Threading.Thread
- C#线程类Thread初步
- C#线程类Thread初步
- C#线程类Thread初步
- C#线程类Thread初步
- C#线程类Thread初步
- C#线程类Thread初步
- c# Thread 线程详细讲解
- C#中的线程(Thread)
- C#线程类Thread初步
- C#学习之--线程Thread
- C# Thread 线程状态知识
- C# 线程Thread的Join()方法
- C#向Thread类线程传入参数
- 确定OK6410中触摸屏设备名称
- Python按特定格式实现文件读写
- CSS3 实现导航菜单的 3D 翻转动画效果
- 关于支付宝异步通知的状态
- shell 如何判断某个文件名以某个字符开头
- 06.C#线程Thread
- IntelliJ IDEA导入多个eclipse项目到同一个workspace下
- 键盘按键数字对照表
- 对自动化测试的简单认识
- 组装list对象
- 数据库之使用DML语句更改数据
- Javascript数组方法
- 获得系统时间
- js收藏