Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
how do I set a thread's priority in Java?
I have been investigating why both my threads can't run at the same time and I found that each thread has a priority, and threads that have a higher priority are executed in preference to threads with a lower priority (if you don't believe me go into eclipse, type the word Thread, and hover over it with your mouse). I believe setting both of my threads to the same priority might solve my issue. Any help on doing this?
Wow, I didn't even think about that (and seeing as I ran into this problem in the past, you would think I would have). Now I guess I have to start thinking of ways to reduce my code... I think. I have gotten myself confused. :P
1 Answer
- RatchetrLv 79 years agoFavorite Answer
Nick...If you haven't already written code to set the priority of your threads, then they are ALREADY running at the same priority.
Based on the code you have posted here in the past, I suspect your problem has more to do with thread race conditions and thread starvation.
The question I would ask is how much of the CPU does each of your threads try to use? How much does it really need? How does a thread block when not busy?
It is fairly rare to have to adjust a threads priority. And you should only do it when you are absolutely sure that you understand the thread dynamics of the problem you are working on. I don't think that applies here.