public long getRuntime(){
        // depends on status: synchronize with status updates
        synchronized(statusLock){
            if(status == SearchStatus.INITIALIZING){
                // initializing
                return JamesConstants.INVALID_TIME_SPAN;
            } else if (status == SearchStatus.IDLE || status == SearchStatus.DISPOSED){
                // idle or disposed: check if ran before
                if(stopTime == JamesConstants.INVALID_TIMESTAMP){
                    // did not run before
                    return JamesConstants.INVALID_TIME_SPAN;
                } else {
                    // return total runtime of last run
                    return stopTime - startTime;
                }
            } else {
                // running or terminating
                return System.currentTimeMillis() - startTime;
            }
        }
    }
public long getRuntime ( ) { synchronized ( statusLock ) { if ( status == SearchStatus . INITIALIZING ) { return JamesConstants . INVALID_TIME_SPAN ; } else if ( status == SearchStatus . IDLE || status == SearchStatus . DISPOSED ) { if ( stopTime == JamesConstants . INVALID_TIMESTAMP ) { return JamesConstants . INVALID_TIME_SPAN ; } else { return stopTime - startTime ; } } else { return System . currentTimeMillis ( ) - startTime ; } } }
<p>
Get the runtime of the <i>current</i> (or last) run, in milliseconds. The precise return value
depends on the status of the search:
</p>
<ul>
<li>
If the search is either RUNNING or TERMINATING, this method returns the time elapsed since
the current run was started.
</li>
<li>
If the search is IDLE or DISPOSED, the total runtime of the last run is returned, if any. Before
the first run, {@link JamesConstants#INVALID_TIME_SPAN} is returned.
</li>
<li>
While INITIALIZING the current run, {@link JamesConstants#INVALID_TIME_SPAN} is returned.
</li>
</ul>
<p>
The return value is always positive, except in those cases when
{@link JamesConstants#INVALID_TIME_SPAN} is returned.
</p>

@return runtime of the current (or last) run, in milliseconds