public void ReaderWriterSlim_WhenDeadlocked_Throws() { ReaderWriterSlimClass rw = new ReaderWriterSlimClass(); Barrier barrier = new Barrier(2); int i = 0; Action t1 = () => rw.Read( () => { barrier.SignalAndWait(); lock (rw) { i = 1; } }); Action t2 = () => { lock (rw) { barrier.SignalAndWait(); rw.Write(i, () => { }); } }; TestHelpers.InvokeSimultaneouslyAndWaitForDeadlockDetection(t1, t2); }
public void ReaderWriterSlim_WhenDeadlocked_Throws() { ReaderWriterSlimClass rw = new ReaderWriterSlimClass(); Barrier barrier = new Barrier(2); int i = 0; Action t1 = () => rw.Read( () => { barrier.SignalAndWait(); lock (rw) { i = 1; } }); Action t2 = () => { lock (rw) { barrier.SignalAndWait(); rw.Write(i, () => { }); } }; TestHelpers.InvokeSimultaneouslyAndWaitForDeadlockDetection(t1, t2); }