Reputation: 26418
As we know that even main is also a thread. So just for the curiosity, is it possible to set the priority for the main thread?
Upvotes: 5
Views: 2346
Reputation: 147164
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.
Upvotes: 0
Reputation: 533530
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.
Upvotes: 0