Created
December 1, 2015 10:34
-
-
Save gravityfox/a74fe4024a225486a80c to your computer and use it in GitHub Desktop.
For Gabizou
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
public static ReadWriteLock getNewLock() { | |
if (FGConfigManager.getInstance().threadSafe()) { | |
return new ReentrantReadWriteLock(); | |
} else { | |
return new ReadWriteLock() { | |
private final Lock lock = new Lock() { | |
@Override | |
public void lock() { | |
} | |
@Override | |
public void lockInterruptibly() throws InterruptedException { | |
} | |
@Override | |
public boolean tryLock() { | |
return true; | |
} | |
@Override | |
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { | |
return true; | |
} | |
@Override | |
public void unlock() { | |
} | |
@Override | |
public Condition newCondition() { | |
throw new UnsupportedOperationException(); | |
} | |
}; | |
@Override | |
public Lock readLock() { | |
return this.lock; | |
} | |
@Override | |
public Lock writeLock() { | |
return this.lock; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment