Skip to content

Instantly share code, notes, and snippets.

@ahmedhosnypro
Created July 16, 2022 20:12
Show Gist options
  • Save ahmedhosnypro/ab698a26a51a2f4c999257e54f254afb to your computer and use it in GitHub Desktop.
Save ahmedhosnypro/ab698a26a51a2f4c999257e54f254afb to your computer and use it in GitHub Desktop.
ReadWriteLock lock = new ReentrantReadWriteLock();
// write
lock.writeLock().lock();
gson.toJson(data, writer);
lock.writeLock().unlock();
// read
lock.readLock().lock();
var objectMap = readData();
lock.readLock().unlock();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment