⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 java基础方面的一些实例代码
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -