示例#1
0
 public Consumer(ChapterContent4 context)
 {
     Id   = context.consumers.Count + 1;
     Name = string.Format("消费者{0}", Id);
     StartConsume(context);
     context.consumers.Add(this);
 }
示例#2
0
 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);
 }
示例#3
0
 public Producer(ChapterContent4 context)
 {
     Id   = context.producers.Count + 1;
     Name = string.Format("生产者{0}", Id);
     StartProduce(context);
     context.producers.Add(this);
 }