1

我试图通过放置以下内容来增加应用程序中线程的优先级:

Thread.currentThread().setPriority(N);

当前线程的正常优先级是 5,我可以更改N为低至 1,但如果我将其设置为 0 或 -1,我会在手机上收到强制关闭消息。

我不能增加这个线程的优先级有什么原因吗?

4

1 回答 1

2

If you look at the documentation for Thread.setPriority(), it says the priority must be in a range defined by MAX_PRIORITY (10) and MIN_PRIORITY (1). Since 0 and -1 are outside that range you should be seeing an IllegalArgumentException.

于 2012-11-14T15:56:13.353 回答