Code example for ConcurrentLinkedQueue

Methods: offer, poll, size

0
		private TileGeneratorPool(int maxSize) {
			mMaxSize = maxSize;
		} 
 
		public TileGenerator get() { 
			TileGenerator i = mPool.poll();
			if (i == null) {
				return new TileGenerator(); 
			} 
			return i;
		} 
 
		public void restore(TileGenerator tileGenerator) {
			if (mPool.size() < mMaxSize && mPool.offer(tileGenerator)) {
				return; 
			} 
			// pool is too big or returning to pool failed, so just try to clean 
			// up. 
			tileGenerator.cleanUp();
		} 
	}