MidiSystem.getMidiDeviceInfo()获取完整的提供程序列表,并从每个提供程序中提取设备的信息.
MIDIs提供程序列表从JDK底层类别com.sun.media.sound.JDK13Services中恢复,通过静态方法getProviders()
public static synchronized List getProviders(Class serviceClass)
Obtains a List containing installed
instances of the providers for the
requested service. The List of
providers is cached for the period of
time given by cachingPeriod . During
this period, the same List instance is
returned for the same type of
provider. After this period, a new
instance is constructed and returned.
The returned List is immutable.
所以,这个类似乎在你的缓存中保存了你的提供者列表,一段时间后会被重新加载.您可以使用setCachingPeriod(int seconds)方法将此时段设置为自定义值.只要我知道,默认缓存期间设置为60秒.
例如,要每秒刷新此缓存,您可以将此行添加到您的代码中:
com.sun.media.sound.JDK13Services.setCachingPeriod(1);
请注意,这个解决方案使用了Sun Propietary类,所以它不能100%便携.