Skip to content

Instantly share code, notes, and snippets.

@gravityfox
Created December 1, 2015 10:34
Show Gist options
  • Save gravityfox/a74fe4024a225486a80c to your computer and use it in GitHub Desktop.
Save gravityfox/a74fe4024a225486a80c to your computer and use it in GitHub Desktop.
For Gabizou
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