使用jstack来分析最耗费CPU的线程,我能够发现AudioSystem.getMixer()调用占用了我所有的CPU。我没有改变代码中的任何内容,只有java版本(从7u51到7u55)。这个调用在一个线程中紧密循环,暂停只持续20ms。关于如何开始寻找解决方案的任何想法?
我正在运行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)