1

我有一个遗留应用程序,它在 Java 8 JVM 中启动,参数如下:

-XX:ThreadPriorityPolicy=42 

我正在尝试在 Java 10 JVM 中运行相同的应用程序。但是,这会在启动时遇到错误:

intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 ... 1 ]
Improperly specified VM option 'ThreadPriorityPolicy=42'

这可能是由于 JVM 实现的变化转移到了 HotSpot JVM 的更高版本。我发现了一些关于 Cassandra 和这个问题的问题,但是我找不到任何文档/问题跟踪来记录 JVM 中的这个变化。有什么地方我可以读到这个吗?

可能出于正当理由将此参数添加到遗留应用程序中。在 Java 10 中我应该如何最好地处理这个问题?将值设置为1? 省略论证?

4

1 回答 1

1

不知道它是否会帮助你,但这里是来自来源的描述:

 "0 : Normal.                                                          "\
      "    VM chooses priorities that are appropriate for normal       "\
      "    applications. On Solaris NORM_PRIORITY and above are mapped "\
      "    to normal native priority. Java priorities below "           \
      "    NORM_PRIORITY map to lower native priority values. On       "\
      "    Windows applications are allowed to use higher native       "\
      "    priorities. However, with ThreadPriorityPolicy=0, VM will   "\
      "    not use the highest possible native priority,               "\
      "    THREAD_PRIORITY_TIME_CRITICAL, as it may interfere with     "\
      "    system threads. On Linux thread priorities are ignored      "\
      "    because the OS does not support static priority in          "\
      "    SCHED_OTHER scheduling class which is the only choice for   "\
      "    non-root, non-realtime applications.                        "\
 "1 : Aggressive.                                                 "\
      "    Java thread priorities map over to the entire range of      "\
      "    native thread priorities. Higher Java thread priorities map "\
      "    to higher native thread priorities. This policy should be   "\
      "    used with care, as sometimes it can cause performance       "\
      "    degradation in the application and/or the entire system. On "\
      "    Linux this policy requires root privilege.") 
于 2018-04-04T13:34:06.253 回答