Setting priority to Java's threads

前端 未结 5 2084
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 20:14

I have a program that runs in a few threads. The main thread shares an object with the other threads and in the main I have a call to:

synchronized(obj){
            


        
5条回答
  •  孤独总比滥情好
    2020-11-27 20:28

    The series of articles here indicate some complexities in the management of thread priorities on various platforms.

    I wonder if your fundamental problem is simply that your worker threads are very CPU intensive and hence rarely reach a point where they would naturally "let go" of the processor (for example by doing some IO or sleeping.) If such is the case then you might include some calls to yield() in those workers, hence giving other Threads more of a chance.

提交回复
热议问题