isAlive problem..Help to understand how it works
- by max
I get this error:
"non-static method isAlive() cannot be referenced from a static context"
what's wrong with this code..please.
I'd like to detect if the thread is alive...
Any help in terms of code will be highly appreciated..thanks
max
class RecThread extends Thread {
public void run() {
recFile = new File("recorded_track.wav");
// Output file type
AudioFileFormat.Type fileType = null;
fileType = AudioFileFormat.Type.WAVE;
// if rcOn =1 thread is alive
int rcOn;
try {
// starts recording
targetDataLine.open(audioFormat);
targetDataLine.start();
AudioSystem.write(new AudioInputStream(targetDataLine),
fileType, recFile);
if (RecThread.isAlive() == true) {
rcOn =1;
}
else {
rcOn =0;
}
} catch (Exception e) {
showException(e);
}
// update actions
recAction.setEnabled(true);
stopRecAction.setEnabled(false);
}
}