public Ferry() { FerryThread = new Thread(new ThreadStart(MoveFerry)); Coast = CoastEnum.WestCoast; _ferryAction = Actions.FerryWait; Cars = new Stack <Car>(); _timer = new Stopwatch(); _timer.Start(); }
public Ferry() { FerryThread = new Thread(new ThreadStart(MoveFerry)); FerryThread.Priority = ThreadPriority.AboveNormal; Coast = CoastEnum.WestCoast; Cars = new Stack <Car>(); _timer = new Stopwatch(); _timer.Start(); }
private void MoveEastCoast() { Console.WriteLine("Ferry Move to East Coast"); Thread.Sleep(1000); Coast = CoastEnum.EastCoast; Monitor.PulseAll(this); Monitor.Wait(this); MoveFerry(); }
private void MoveEastCoast() { lock (this) { _ferryAction = Actions.FerryMove; } Console.WriteLine(" Ferry Move to East Coast"); Thread.Sleep(1000); lock (this) { Coast = CoastEnum.EastCoast; _ferryAction = Actions.FerryWait; } MoveFerry(); }
private void MoveWestCoast() { Console.WriteLine("Ferry Move to West Coast"); Thread.Sleep(1000); _timer.Restart(); Coast = CoastEnum.WestCoast; ++_courses; Monitor.PulseAll(this); //if (_courses == (CarsCount % FerryCapacity + 1)) //{ // FerryThread.Abort(); //} Monitor.Wait(this); MoveFerry(); }
private void MoveWestCoast() { lock (this) { _ferryAction = Actions.FerryMove; } Console.WriteLine(" Ferry Move to West Coast"); Thread.Sleep(1000); lock (this) { _courses = 0; _timer.Restart(); Coast = CoastEnum.WestCoast; _ferryAction = Actions.FerryWait; } MoveFerry(); }
private void MoveWestCoast() { lock(this) { _ferryAction = Actions.FerryMove; } Console.WriteLine(" Ferry Move to West Coast"); Thread.Sleep(1000); lock(this) { _courses = 0; _timer.Restart(); Coast = CoastEnum.WestCoast; _ferryAction = Actions.FerryWait; } MoveFerry(); }
private void MoveEastCoast() { lock(this) { _ferryAction = Actions.FerryMove; } Console.WriteLine(" Ferry Move to East Coast"); Thread.Sleep(1000); lock(this) { Coast = CoastEnum.EastCoast; _ferryAction = Actions.FerryWait; } MoveFerry(); }