Code example for ArrayBlockingQueue

Methods: adddrainTosize

			double z = event.values[2];
			double m = Math.sqrt(x*x + y*y + z*z);
			// Add m to the mAccBuffer one by one. 
			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 = newBuf;
				mAccBuffer.add(new Double(m));
Connect your IDE to all the code out there  Get Codota for Java