-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests for ReentrantReadWriteLock (#76)
- Loading branch information
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...test/src/main/java/org/pastalab/fray/test/fail/rwlock/ReentrantReadWriteLockDeadlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.pastalab.fray.test.fail.rwlock; | ||
|
||
import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
|
||
public class ReentrantReadWriteLockDeadlock { | ||
public static void main(String[] args) throws InterruptedException { | ||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); | ||
lock.writeLock().lock(); | ||
Thread t = new Thread(() -> { | ||
lock.readLock().lock(); | ||
}); | ||
t.start(); | ||
t.join(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...va/org/pastalab/fray/test/success/rwlock/ReentrantReadWriteLockDowngradingNoDeadlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.pastalab.fray.test.success.rwlock; | ||
|
||
import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
|
||
public class ReentrantReadWriteLockDowngradingNoDeadlock { | ||
public static void main(String[] args) throws InterruptedException { | ||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); | ||
lock.writeLock().lock(); | ||
lock.readLock().lock(); | ||
lock.writeLock().unlock(); | ||
Thread t = new Thread(() -> { | ||
lock.readLock().lock(); | ||
}); | ||
t.start(); | ||
t.join(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...src/main/java/org/pastalab/fray/test/success/rwlock/ReentrantReadWriteLockNoDeadlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.pastalab.fray.test.success.rwlock; | ||
|
||
import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
|
||
public class ReentrantReadWriteLockNoDeadlock { | ||
public static void main(String[] args) throws InterruptedException { | ||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); | ||
lock.readLock().lock(); | ||
Thread t = new Thread(() -> { | ||
lock.readLock().lock(); | ||
}); | ||
t.start(); | ||
t.join(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters