为什么线程不结束
这个是获取声音文件长度的函数,在main中调用 时线程不会结束,为什么
public static double getLength(String path)throws Exception{
AudioInputStream stream;
stream = AudioSystem.getAudioInputStream(new URL(path));
// At present, ALAW and ULAW encodings must be converted
// to PCM_SIGNED before it can be played
AudioFormat format = stream.getFormat();
if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
format = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
format.getSampleSizeInBits()*2,
format.getChannels(),
format.getFrameSize()*2,
format.getFrameRate(),
true); // big endian
stream = AudioSystem.getAudioInputStream(format, stream);
}
// Create the clip
DataLine.Info info = new DataLine.Info(
Clip.class, stream.getFormat());
Clip clip = (Clip) AudioSystem.getLine(info);
// This method does not return until the audio file is completely loaded
//clip.open(stream);
clip.stop();
clip.close();
return clip.getBufferSize() /(clip.getFormat().getFrameSize() * clip.getFormat().getFrameRate());
}