class1.cs

来自「c#实现的工作队列」· CS 代码 · 共 56 行

CS
56
字号
using System;
using System.Threading ;

namespace WorkQueue
{
	/// <summary>
	/// Class1 的摘要说明。
	/// </summary>
	class Class1
	{
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: 在此处添加代码以启动应用程序
			//

			new Thread(new ThreadStart(Test.dodo)).Start();

			//Console.WriteLine("start");

			WorkQueue wq = new WorkQueue(2);

			Thread.Sleep(1000);

			for(int i=0;i<100;i++)
			{
				wq.execute(
					new Thread(new ThreadStart((new Test(i)).dodo2))
					);
			}

			Console.WriteLine("ok");
		}
		class Test
		{
			int ii;

			public Test(){}
			public Test(int i){ii=i;}

			public static void dodo()
			{
				System.Console.Write("--{0}-\n",10);
			}
			public void dodo2()
			{
				System.Console.Write("--{0}-\n",ii);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?