You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
646 B
31 lines
646 B
using System;
|
|
using System.Threading;
|
|
|
|
namespace LostSignals
|
|
{
|
|
class Worker
|
|
{
|
|
private ISynch signal;
|
|
private Operator op;
|
|
private String id;
|
|
|
|
public Worker(ISynch signal, Operator op, String id)
|
|
{
|
|
this.signal = signal;
|
|
this.op = op;
|
|
this.id = id;
|
|
}
|
|
|
|
public void Do()
|
|
{
|
|
while (true)
|
|
{
|
|
signal.Acquire();
|
|
Console.WriteLine(id + " released...");
|
|
Thread.Sleep(op.Operation());
|
|
op.Done(id);
|
|
Thread.Sleep(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|