A list and some threads

  • 9
  • Locked
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".
You can't complete this task, because you're not signed in.
Comments (10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Thayalan Ravi
Level 28 , Malaysia
12 February, 04:09
hi can I know, whats the meaning of the below syntax? list.add(new Thread(new SpecialThread()));
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)
Andrew Evans
Level 17 , San Jose, Canada
8 March 2022, 16:18
Why volatile?
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
Justin Smith
Level 38 , Greenfield, USA, United States
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.
Karas Java Developer
1 March 2021, 22:54
Nothing was displayed... still was fine...
Level 20 , Poland
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.
Level 23 , Columbia, United States
11 August 2020, 20:52
Deceptively difficult.
Level 19
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()'".
Roman Grygorczuk
Level 19 , Cracow, Poland
31 December 2020, 09:06
Confusing is a part of the learning process. Keep it up!