Change queue to concurrentlinkedqueue to avoid unsafe concurrent accesses.