您的位置:首页 > 其它

编写一个程序,开启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()

        {

           

           

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: