I playing a sound file, and I create a new thread every time the playSoundFile() method is called. I just need to know how to pass the information from the method call into run() within the thread, so It can be used within.
public void playSoundFile(File file) {//http://java.ittoolbox.com/groups/technical-functional/java-l/sound-in-an-application-90681
new Thread(
new Runnable() {
public void run() {
try {
//get an AudioInputStream
//this input stream can't use the file passed to playSoundFile()
AudioInputStream ais = AudioSystem.getAudioInputStream(file);
...
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
Simply declare the variable to be
final, then you can use it in your anonymous inner class: