Code example for TimeoutException

    public void put(Thread t, long timeoutMS) throws InterruptedException, TimeoutException
        if (!queue.offer(new WeightedQueue.Entry(t), timeoutMS, TimeUnit.MILLISECONDS))
            throw new TimeoutException("Failed to acquire request scheduler slot for '" + key + "'");
    public Thread poll()
        Entry e = queue.poll();
        if (e == null)
            return null; 
        stats.addNano(System.nanoTime() - e.creationTime);
        return e.thread;
    public String toString()
Connect your IDE to all the code out there  Get Codota for Java