//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertBothSucceeds(Runnable lockAction1, Runnable lockAction2) throws Throwable private void AssertBothSucceeds(ThreadStart lockAction1, ThreadStart lockAction2) { AssertUU(); Race race = new Race(); LockContestant c1 = new LockContestant(lockAction1); LockContestant c2 = new LockContestant(lockAction2); // when race.AddContestant(c1); race.AddContestant(c2); race.Go(); // then Pair <bool, bool> c1State = c1.State(); Pair <bool, bool> c2State = c2.State(); assertTrue(WithState("Expected both to acquire lock.", c1State, c2State), c1State.First() && c2State.First()); assertTrue(WithState("Expected both to be started.", c1State, c2State), c1State.Other() && c2State.Other()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertOnlyOneSucceeds(Runnable lockAction1, Runnable lockAction2) throws Throwable private void AssertOnlyOneSucceeds(ThreadStart lockAction1, ThreadStart lockAction2) { AssertUU(); Race race = new Race(); LockContestant c1 = new LockContestant(lockAction1); LockContestant c2 = new LockContestant(lockAction2); // when race.AddContestant(c1); race.AddContestant(c2); race.GoAsync(); while (!(c1.LockAcquired() || c2.LockAcquired()) || !(c1.Started() && c2.Started())) { LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(1)); } // then Pair <bool, bool> c1State = c1.State(); Pair <bool, bool> c2State = c2.State(); assertNotEquals(WithState("Expected exactly one to acquire lock.", c1State, c2State), c1State.First(), c2State.First()); assertTrue(WithState("Expected both to be started.", c1State, c2State), c1State.Other() && c2State.Other()); }