Methods Summary |
---|
public void | destroyApp(boolean unconditional)Destroy must cleanup everything. The thread is signaled
to stop and no result is produced.
thread = null;
System.out.println("destroyApp");
|
void | empty()An Empty method.
|
public void | pauseApp()Pause signals the thread to stop by clearing the thread field.
If stopped before done with the iterations it will
be restarted from scratch later.
thread = null;
System.out.println("pauseApp");
|
public void | run()Run the timing test, measure how long it takes to
call a empty method 1000 times.
Terminate early if the current thread is no longer
the thread from the
Thread curr = Thread.currentThread(); // Remember current thread
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000 && thread == curr; i++) {
empty();
}
long end = System.currentTimeMillis();
// Check if timing was aborted, if so just exit
// The rest of the application has already become quiescent.
if (thread != curr) {
return;
}
long millis = end - start;
// Reporting the elapsed time is outside the scope of this example.
System.out.println("Elapsed " + millis + " ms.");
// All done cleanup and quit
destroyApp(true);
notifyDestroyed();
|
public void | startApp()Start creates the thread to do the timing.
It should return immediately to keep the dispatcher
from hanging.
thread = new Thread(this);
thread.start();
System.out.println("startApp");
|