SubmissionReceipt () { synchronized (myLock) { // don't be fooled by AtomicLong. We need "synchronized" to make sure that mySubmittedTaskCount and myTasksQueue are changing together return new SubmissionReceipt(mySubmittedTasksCount.get()); } }