Code example for ArrayBlockingQueue

Methods: add, drainTo, size

0
					* event.values[2]);
 
			// Inserts m to mAccBuffer 
 
			try { 
				mAccBuffer.add(Double.valueOf(m));
 
			} catch (IllegalStateException e) {
				// Catches Exception when the mAccBuffer reaches the capacity.  
				// here you need to increase the buffer size,  
				// easy way is to just set it to the double of it.  
				ArrayBlockingQueue<Double> newBuf = new ArrayBlockingQueue<Double>(
						mAccBuffer.size() * 2);
				mAccBuffer.drainTo(newBuf);
				mAccBuffer = newBuf;
				mAccBuffer.add(Double.valueOf(m));
			} 
		} 
	} 
 
	public void onAccuracyChanged(Sensor sensor, int accuracy) {