Why ++i ? You are checking task ids in range from 2 to Long.MAX_VALUE. Why do you not check task id 1?