|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
jAudioFeatureExtractor.BatchExecutionThread
public class BatchExecutionThread
GUI components that handles the execution of the feature extraction. The unusual structure is to get around the limitations of Swing - since swing is not thread safe, gui componenets can only operate from the main thread without race conditions. This means that either long running activities must execute on the main thread (making the system unresponsive) or fire updates on the main thread, potentially causing race conditions. This problem can be circumvented by pumping updates to the main event thread via small runnable objects (Geary 1999, 281-91). It works, but makes for obscure code with several inner or anonymous classes that encapsulate a message to the gui thread.
Geary, D. 1999. Graphic Java 2: Mastering the JFC. Palo Alto: Sun Microsystems.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
BatchExecutionThread(Controller controller,
OuterFrame of)
Creates a new thread. |
Method Summary | |
---|---|
void |
announceUpdate(int fileDone)
Called at periodic intervals during the execution of the code. |
void |
announceUpdate(int fileNumber,
int fileDone)
Called after each file executes |
void |
run()
Executes a batch. |
void |
setFileLength(int windows)
Informs the file progress bar on how many windows of data are present in this file. |
void |
setNumberOfFiles(int files)
Informs the batch progress bar about many files are present in this batch. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BatchExecutionThread(Controller controller, OuterFrame of)
controller
- Near global object containing actions and model components.of
- Reference to the main frame so it can be disabled during
execution - preventing modification to the system in mid run.Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void announceUpdate(int fileNumber, int fileDone)
announceUpdate
in interface Updater
fileNumber
- How many files are completed.fileDone
- Position in the file (usually 0).public void announceUpdate(int fileDone)
announceUpdate
in interface Updater
fileDone
- Position in file.public void setNumberOfFiles(int files)
setNumberOfFiles
in interface Updater
files
- Number of files to be processed.public void setFileLength(int windows)
setFileLength
in interface Updater
windows
- Total number of windows of data to be processed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |