Lock the size() function in BlockQueue to prevent unsynchronization