isAlive problem..Help to understand how it works
Posted
by
max
on Stack Overflow
See other posts from Stack Overflow
or by max
Published on 2011-01-12T09:13:38Z
Indexed on
2011/01/12
9:54 UTC
Read the original article
Hit count: 167
java
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); } }
© Stack Overflow or respective owner