Is it possible to set the priority for the main thread?
As we know that even main is also a thread. So just for t开发者_运维知识库he curiosity, is it possible to set the priority for the main thread?
Have you tried
Thread.currentThread().setPriority();
Its worth noting that this is just a hint to the OS and unless you are administrator or root it might not do anything. Even then it may not help very much. setPriority() is harmless AFAIK.
IIRC, generally setting the priority of a running thread will have no effect. An old trick was to always kick off another thread and abandon main. Indeed this is what the Sun/Oracle JVM now does on Linux in order to change the stack size.
Setting the priority of a thread is typically misguided. Many JRE versions will ignore it altogether.
精彩评论