Code example for Lock

Methods: lock, unlock

0
	private static Queue<String> mUploadFileQueue = new LinkedList<String>();
	private final static ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
	private final static Lock readLock = readWriteLock.readLock();
	private final static Lock writeLock = readWriteLock.writeLock();
	public static void addUploadFile(String _task) {
		writeLock.lock();
		try { 
			mUploadFileQueue.add(_task);
		} finally { 
			writeLock.unlock();
		} 
	} 
	public static String removeUploadFile() {
		writeLock.lock();
		try { 
			if (!mUploadFileQueue.isEmpty()) {
				return mUploadFileQueue.remove();
			} else { 
				return null; 
			} 
		} finally {