CodeGym /Courses /Java Multithreading /Practice with thread pools

Practice with thread pools

Java Multithreading
Level 8, Lesson 8
Available

"Hi, Amigo!"

16
Task
Java Multithreading, level 8, lesson 8
Locked
Introducing Executors
Introducing Executors
16
Task
Java Multithreading, level 8, lesson 8
Locked
Introducing ThreadPoolExecutor
Introducing ThreadPoolExecutor
9
Task
Java Multithreading, level 8, lesson 8
Locked
shutdownNow!
shutdownNow!
Comments (8)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Justin Smith Level 41, Greenfield, USA, United States
2 May 2022
They have the difficulties backwards on this set of tasks. The first two are easy (they literally tell you every step of the process). The last one is hard. I've been googling for a bit and I still have no idea how to even approach this. I thought maybe enclosing the method call in a try/catch with InterruptedException but it just says that it never throws that type of exception. I tried putting the Runnable objects in an arraylist so that i could iterate through them after the shutdownnow method to find out which ones were interrupted, but that's not working either.
Niko Level 41, Wuhan, China
2 April 2022
1.创建ExecutorService实例,并用submit方法添加任务。或者创建ThreadPoolExecutor实例,用prestartAllCoreThreads启动核心线程。 2.shutdown()会关闭executor,但是已经添加的任务会被完成。shutdownNow()会立即关闭executor并且返回已经添加但是没有完成的任务。
Maria Level 34, Utrecht, Netherlands
18 November 2020
shutdownNow() returns list...
Andrei Level 41
17 May 2021
I was thinking where are the rest of the threads? Is my computer so fast that is executes all of them before it has time to call the shutdown method? 😂
Dawn( #11020889) Level 37, Toronto, Canada
23 April 2023
u r very cool!
catalin1989 Level 37, Romania
12 March 2024
Thanx. This was the key to solving the last task. I often find useful information in the comment section.
fzw Level 41, West University Place, United States
20 May 2020
Task3: The example output conflicts with validation. Do not remove square brackets when printing Runnable
Luyi Level 31, Kosice, Slovakia
7 April 2020
for "Introducing ThreadPoolExecutor" check link: https://stackoverflow.com/questions/17659510/core-pool-size-vs-maximum-pool-size-in-threadpoolexecutor