Stops the stopwatch. Future reads will return the fixed duration that had elapsed up to this point. @return this {@code Stopwatch} instance @throws IllegalStateException if the stopwatch is already stopped.
()
| 176 | * @throws IllegalStateException if the stopwatch is already stopped. |
| 177 | */ |
| 178 | @CanIgnoreReturnValue |
| 179 | public Stopwatch stop() { |
| 180 | long tick = ticker.read(); |
| 181 | checkState(isRunning, "This stopwatch is already stopped."); |
| 182 | isRunning = false; |
| 183 | elapsedNanos += tick - startTick; |
| 184 | return this; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Sets the elapsed time for this stopwatch to zero, and places it in a stopped state. |
no test coverage detected