开发者

How do I use the setPriority() method correctly?

开发者 https://www.devze.com 2023-03-13 20:03 出处:网络
Here\'s a question on a test that I got wrong, I\'m confused by how setPriority(Thread.MIN_Priority) and setPriority(1) differ.

Here's a question on a test that I got wrong, I'm confused by how setPriority(Thread.MIN_Priority) and setPriority(1) differ.

Q: Assume your multithreaded program has a background thread (called batchThread) which does some lengthy processing, what would be t开发者_JS百科he proper way of setting its priority to allow the rest of the system to be very responsive while batchThread is running?

a) batchThead.setPriority(1);

b) batchThead.setPriority(Thread.MAX_PRIORITY);

c) batchThead.setPriority(Thread.MIN_PRIORITY);

d) batchThead.setPriority(Thread.MID_PRIORITY);

I chose C and got it wrong. Appreciate the help as always.


I believe they're one in the same. According to the Java docs, Thread.MIN_PRIORITY is 1: http://download.oracle.com/javase/1.4.2/docs/api/constant-values.html#java.lang.Thread.MAX_PRIORITY

Perhaps your instructor was mistaken?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号