Code example for ReentrantReadWriteLock

Methods: readLock, writeLock

0
 * @param <T>  
 */ 
public class WorldObjectTree<T extends L2Object> extends L2ObjectMap<T> 
{ 
	private final TreeMap<Integer, T> _objectMap = new TreeMap<Integer,T>();
	private final ReentrantReadWriteLock _rwl = new ReentrantReadWriteLock();
	private final Lock _r = _rwl.readLock();
	private final Lock _w = _rwl.writeLock();
	 
	/** 
	 * @see com.l2jserver.gameserver.util.L2ObjectMap#size() 
	 */ 
	@Override 
	public int size() 
	{ 
		_r.lock();
		try { 
			return _objectMap.size();
		} 
		finally { _r.unlock(); }
	}