Setting priority to Java's threads

前端 未结 5 2072
没有蜡笔的小新
没有蜡笔的小新 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:41

    You have a setPriority() method in the Thread class.

    Check this javadoc.

    Setting thread priority to maximum:

    public static void main(String args[]) {
        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        // Your main code.
    }
    

提交回复
热议问题