编写一个程序,开启3个线程,这3个线程的ID分别为A、B、C,每个线程将自己的ID在屏幕上打印10遍,要求输出结果必须按ABC的顺序显示;如:ABCABC….依次递推
2016-05-14 00:10
931 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleApplication16
{
class Program
{
static string str1;
static string str2;
static string str3;
static string str = null;
static void Main(string[] args)
{
Thread td1 = new Thread(Print);
str1= td1.ManagedThreadId.ToString();
Thread td2 = new Thread(Print);
str2 = td2.ManagedThreadId.ToString();
Thread td3 = new Thread(Print);
str3 = td3.ManagedThreadId.ToString();
str = str1 + str2 + str3;
for (int i = 0; i < 10; i++)
{
Console.WriteLine(str);
}
Console.ReadKey();
}
static void Print()
{
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleApplication16
{
class Program
{
static string str1;
static string str2;
static string str3;
static string str = null;
static void Main(string[] args)
{
Thread td1 = new Thread(Print);
str1= td1.ManagedThreadId.ToString();
Thread td2 = new Thread(Print);
str2 = td2.ManagedThreadId.ToString();
Thread td3 = new Thread(Print);
str3 = td3.ManagedThreadId.ToString();
str = str1 + str2 + str3;
for (int i = 0; i < 10; i++)
{
Console.WriteLine(str);
}
Console.ReadKey();
}
static void Print()
{
}
}
}
相关文章推荐
- 2012年第三届蓝桥杯C/C++程序设计本科B组决赛
- bzoj3295【CQOI2011】动态逆序对
- win7 64位安装redis 及Redis Desktop Manager使用
- MyBatis主流程分析之(二)-打开会话和数据库操作
- Java获取WEB目录路径
- ViewPager三个步骤
- 主席树入门+模板 POJ 2104
- java-web易错汇总
- Qt(三)--- 实现QQ登陆界面头像状态栏的功能
- Java设计模式之策略设计模式
- new TextView
- POJ 1053 Integer Inquiry (大数加法,还是Java大法好)
- git的学习笔记(与小伙伴协作)
- POJ-3281 Dining (最大流[Ford-Fulkerson])
- java jdbc编程,运行总显示不允许链接
- 5.13 有关游戏设计的总结
- Hadoop I/O操作原理整理
- Block全面分析
- Java泛型 泛型的上下限
- Codeforces Round #347 (Div. 2) B. Rebus