StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
System.out.println("bat dau chay" + Calendar.getInstance()); Callable callable1 = new Callable() { @Override public String call() throws Exception { System.out.println("task 1"); return "task --1"; } }; Callable callable2 = new Callable() { @Override public String call() throws Exception { System.out.println("task 2"); return "task --2"; } }; Callable callable3 = new Callable() { @Override public String call() throws Exception { System.out.println("task 3"); return "task --3"; } }; List<Callable> callables = new ArrayList(); callables.add(callable1); callables.add(callable2); callables.add(callable3); callables.add(callable1); callables.add(callable2); callables.add(callable3); callables.add(callable1); callables.add(callable2); callables.add(callable3); ExecutorService executorService = Executors.newFixedThreadPool(5); List<Future> futures = executorService.invokeAll(callables); for (Future f : futures) { System.out.println(f.get()); } System.out.println("ket thuc" + Calendar.getInstance()); executorService.shutdown();
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Input your email to receive reset password link, or if you remember your password, you can click