private void addJob(Object job, boolean isPrefetch) {
        if(job == null ||
           (job != WorkerThread.TERMINATE && !(job instanceof Job))) {
            // Programming error: deliberately no message.
            throw new IllegalArgumentException();
        }

        LinkedList jobQueue;
        synchronized(jobQueue = getQueue(isPrefetch)) {
            if(isPrefetch ||
               jobQueue.isEmpty() ||
               job instanceof RequestJob) {
                // Append job to queue.
                jobQueue.addLast(job);
            } else {
                // If the queue is non-empty or the job is a TileJob
                // insert the job after the last TileJob in the queue.
                boolean inserted = false;
                for(int idx = jobQueue.size() - 1; idx >= 0; idx--) {
                    if(jobQueue.get(idx) instanceof TileJob) {
                        jobQueue.add(idx+1, job);
                        inserted = true;
                        break;
                    }
                }
                if(!inserted) {
                    jobQueue.addFirst(job);
                }
            }
            jobQueue.notify();
        }
    }