Let's multiply threads again and again. In the main method, add five threads to the static list. Each thread must be a new Thread object that works with its own SpecialThread object. The SpecialThread class's run method should display "This is the run method inside SpecialThread".
A list and some threads
- 9
Locked
Comments (10)
- Popular
- New
- Old
You must be signed in to leave a comment
Thayalan Ravi
12 February, 04:09
hi can I know, whats the meaning of the below syntax?
list.add(new Thread(new SpecialThread()));
0
Jonaskinny Java Developer at Sandmedia
10 March 2022, 04:22
can do it all in one simple line (tip...we don't need references to the Threads since they are in a list)
0
Andrew Evans
8 March 2022, 16:18
Why volatile?
0
Jonaskinny Java Developer at Sandmedia
10 March 2022, 04:25
so the List of threads wont be cached. Best practice, not specific to this task
0
Justin Smith
3 September 2021, 14:15
The conditions are somewhat misleading since they give the impression the final code must display "This is the run method inside SpecialThread". Just ignore that condition, this shouldn't print anything to pass validation.
I was also really confused by the two words "works with". I read that and had no idea what that meant. This is the first time I've seen that as a way of saying that one thing needs another thing as an argument.
0
Karas Java Developer
1 March 2021, 22:54
Nothing was displayed... still was fine...
0
Vitalina
16 December 2020, 19:48
A tip:
You don't have to call Thread.start() method.
1) Create the object
2) Create a thread
3) Add thread to the list.
0
Petros
11 August 2020, 20:52
Deceptively difficult.
0
Felix
8 April 2020, 01:41
I didnt really get why I need to start the threads using the run() method and start() doesn't get through the valitadion. IntelliJ confused me even more stating "Calls to 'run()' should probably be replaced with 'start()'".
0
Roman Grygorczuk
31 December 2020, 09:06
Confusing is a part of the learning process. Keep it up!
0