In a separate file, create a class called MyThread that inherits Thread. MyThread must:
1. Be able to be created using any of the superclass's constructors (Alt+Insert).
2. Thread priorities must be set using a loop—from the minimum to the maximum value.
Thread priorities
- 16
Locked
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
klesk
16 March 2021, 07:49
I think maybe this requirement
should be changed. You don't need an extra loop to set the priorities, you already have 2 for-loops. I think appropriate would be, set the priority each time a new thread is created or something similar. +2
Justin Smith
30 April 2022, 13:26
Yes, you also don't actually have to use MIN_PRIORITY anywhere in the code despite that it tells you to. Also the official solution (I always check this after finishing to compare) is unnecessarily complicated compared with what I used to pass. Unnecessary use of volatile keyword, unnecessary extra conditional checks, unnecessary use of the getMaxPriority method (tip: if you try to set the priority higher than the group max priority, it will simply cap it at the group max priority, use this to your advantage here).
0