--- title: "此 JDK 不支持线程 CPU 时间 – 如何解决此 Elasticsearch 异常" date: 2026-03-06 lastmod: 2026-03-06 description: "Elasticsearch尝试访问线程CPU时间时,如果当前JDK版本不支持该功能,会抛出'thread CPU time is not supported on this JDK'异常。本文介绍该错误的解决方案。" tags: ["JDK", "线程CPU时间", "异常处理", "版本兼容性"] summary: "版本: 6.8-8.9 简而言之,当 Elasticsearch 尝试访问线程 CPU 时间时,但当前的 Java 开发工具包(JDK)版本不支持该功能时,就会出现此错误。这通常是由于使用了过时或不兼容的 JDK 版本导致的。要解决此问题,您可以升级到支持线程 CPU 时间的较新 JDK 版本。或者,如果线程 CPU 时间对您的操作并不关键,您可以在 Elasticsearch 设置中禁用线程 CPU 时间的使用。 日志上下文 # 日志"thread CPU time is not supported on this JDK"的类名是 HotThreads.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: } String innerDetect(ThreadMXBean threadBean; SunThreadInfo sunThreadInfo; long currentThreadId; SleepFunctionthreadSleep) throws Exception { if (threadBean.isThreadCpuTimeSupported() == false) { throw new ElasticsearchException("thread CPU time is not supported on this JDK"); } if (type == ReportType." --- > **版本:** 6.8-8.9 简而言之,当 Elasticsearch 尝试访问线程 CPU 时间时,但当前的 Java 开发工具包(JDK)版本不支持该功能时,就会出现此错误。这通常是由于使用了过时或不兼容的 JDK 版本导致的。要解决此问题,您可以升级到支持线程 CPU 时间的较新 JDK 版本。或者,如果线程 CPU 时间对您的操作并不关键,您可以在 Elasticsearch 设置中禁用线程 CPU 时间的使用。 日志上下文 ----------- 日志"thread CPU time is not supported on this JDK"的类名是 [HotThreads.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java } String innerDetect(ThreadMXBean threadBean; SunThreadInfo sunThreadInfo; long currentThreadId; SleepFunctionthreadSleep) throws Exception { if (threadBean.isThreadCpuTimeSupported() == false) { throw new ElasticsearchException("thread CPU time is not supported on this JDK"); } if (type == ReportType.MEM && sunThreadInfo.isThreadAllocatedMemorySupported() == false) { throw new ElasticsearchException("thread allocated memory is not supported on this JDK"); } ```