Last active
September 24, 2020 05:39
-
-
Save sne007/8a3de878ca0f0ece4208327927feaf4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tasks { | |
public static void main(String[] args) { | |
ExecutorService executorService = Executors.newFixedThreadPool(3); | |
executorService.submit(new Task1()); | |
executorService.submit(new Task2()); | |
executorService.submit(new Task3()); | |
executorService.shutdown(); | |
} | |
} | |
/* | |
Output: | |
T1 is running on thread pool-1-thread-1 | |
Computed prime number 17 | |
T2 is running on thread pool-1-thread-2 | |
Computed prime number 23 | |
T3 is running on thread pool-1-thread-3 | |
Computed prime number 13 | |
Successfully put 23 in the database | |
Successfully put 17 in the database | |
Successfully put 13 in the database | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment