Created
October 23, 2018 20:39
-
-
Save sauceaaron/92ac9eb47716c3d9890374732dc3add7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import java.util.concurrent.locks.Lock; | |
| import java.util.concurrent.locks.ReadWriteLock; | |
| import java.util.concurrent.locks.ReentrantReadWriteLock; | |
| public class Locking | |
| { | |
| private static final ReadWriteLock locker = new ReentrantReadWriteLock(); | |
| public void lock() | |
| { | |
| Lock lock = locker.readLock(); | |
| try { lock.lock(); } | |
| finally { lock.unlock(); } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Locking.locker.readLock().lock();