使用 jstack 来分析 CPU 最密集的线程,我发现 AudioSystem.getMixer() 调用占用了我所有的 CPU。我没有更改代码中的任何内容,只更改了 java 的版本(从 7u51 到 7u55)。此调用在线程中处于紧密循环中,暂停仅持续 20 毫秒。关于如何开始找到解决方案的任何想法?
我正在运行 Ubuntu 14.04 x86_64 和 JRE 7u55 64 位。这发生在所有较新版本的 java 中。
"MonitorThread" prio=10 tid=0x00007f57bc409000 nid=0x2e36 runnable [0x00007f5778f85000]
java.lang.Thread.State: RUNNABLE
at com.sun.media.sound.DirectAudioDeviceProvider.nGetNumDevices(Native Method)
at com.sun.media.sound.DirectAudioDeviceProvider.init(Unknown Source)
at com.sun.media.sound.DirectAudioDeviceProvider.<init>(Unknown Source)
- locked <0x00000000f07721b0> (a java.lang.Class for com.sun.media.sound.DirectAudioDeviceProvider)
at sun.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.misc.Service$LazyIterator.next(Unknown Source)
at com.sun.media.sound.JSSecurityManager.getProviders(Unknown Source)
- locked <0x00000000f05556e0> (a java.lang.Class for com.sun.media.sound.JSSecurityManager)
at com.sun.media.sound.JDK13Services.getProviders(Unknown Source)
at javax.sound.sampled.AudioSystem.getProviders(Unknown Source)
at javax.sound.sampled.AudioSystem.getMixerProviders(Unknown Source)
at javax.sound.sampled.AudioSystem.getMixer(Unknown Source)
at Client$MonitorAllAudio.run(Client.java:8941)
at java.lang.Thread.run(Unknown Source)