package multiThread;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class Demon2 {
    public static void main(String[] args) {
        ExecutorService exe = Executors.newFixedThreadPool(10);
          
        Future future = exe.submit(new Callable() {
            @Override
            public String call() throws Exception {
                Thread.sleep(10000);
                return "hello thread";
            }
              
        });
          
        try {
            System.out.println(future.get(1000, TimeUnit.MILLISECONDS));
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        } finally {
            exe.shutdown();
        }
    }
}