class1.cs
来自「java基础方面的一些实例代码」· CS 代码 · 共 52 行
CS
52 行
using System;
using System.Threading;
namespace MCaoConsoleApplication1
{
class ThreadJoin
{
[STAThread]
static void Main(string[] args)
{
ThreadJoin obj1 = new ThreadJoin( );
Thread thread1 = new Thread(new ThreadStart(obj1.Writei));
thread1.Name = "第一个间隔40ms循环打印线程";
ThreadJoined obj2 = new ThreadJoined( );
Thread thread2 = new Thread(new ThreadStart(obj2.Anotheri));
thread2.Name = "第二个间隔100ms循环打印线程";
thread2.Start( );
//thread2.Join();
thread1.Start( );
}
private void Writei( )
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(Thread.CurrentThread.Name + " Current count is " + i);
Thread.Sleep(40);
}
}
} // end of class ThreadJoin
class ThreadJoined
{
public void Anotheri( )
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine(Thread.CurrentThread.Name + " add " + i);
Thread.Sleep(100);
}
}
} // end of class ThreadJoined
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?