Code example for ArrayBlockingQueue

Methods: adddrainTosize

			// if no space is currently available. When using a 
			// capacity-restricted queue, it is generally preferable to use 
			// offer. 
			try { 
				mAccBuffer.add(new Double(m));
			} catch (IllegalStateException e) {
				// Exception happens when reach the capacity. 
				// Doubling the buffer. ListBlockingQueue has no such issue, 
				// But generally has worse performance 
				ArrayBlockingQueue<Double> newBuf = new ArrayBlockingQueue<Double>(
						mAccBuffer.size() * 2);
				mAccBuffer = newBuf;
				mAccBuffer.add(new Double(m));
Experience pair programming with AI  Get Codota for Java