Java Thread Executor setTimeout(Long duration, Runnable csr)

Here you can find the source of setTimeout(Long duration, Runnable csr)

Description

set Timeout

License

Open Source License

Declaration

public static void setTimeout(Long duration, Runnable csr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Main {
    public static void setTimeout(Long duration, Runnable csr) {
        final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

        scheduler.schedule(csr, duration, TimeUnit.MILLISECONDS);
    }/*from  w  w w . j  a  v a  2s.  c o m*/
}

Related

  1. getThreadExecutor(int nThreads)
  2. isCorrectCollectionSizeTimeOut(Collection collection, int size, long timeout, TimeUnit unit)
  3. isRegularlyDone(Future future)
  4. isShutdown(Executor executor)
  5. isShutDown(ExecutorService executorService)
  6. submitTask(Runnable command)