public Consumer(ChapterContent4 context) { Id = context.consumers.Count + 1; Name = string.Format("消费者{0}", Id); StartConsume(context); context.consumers.Add(this); }
public void StartConsume(ChapterContent4 context) { context.Log.Text += string.Format("{0}\t{1}开始消费\n", DateTime.Now, Name); Thread = new Thread(new ParameterizedThreadStart(Consume)); Thread.IsBackground = true; Thread.Start(context); }
public Producer(ChapterContent4 context) { Id = context.producers.Count + 1; Name = string.Format("生产者{0}", Id); StartProduce(context); context.producers.Add(this); }