Get the thread that is currently running this OperationRunner
instance.
This value only has meaning when an Operation is running. It depends on
the implementation if the field is unset after an operation is executed
or not. So it could be that a value is returned while no operation is
running.
For example, the
OperationExecutorImpl will never unset this
field since each OperationRunner is bound to a single OperationThread;
so this field is initialized when the OperationRunner is created.
The returned value could be null. When it is null, currently no thread
is running this OperationRunner.
Recommended idiom for slow operation detection:
1: First read the operation and store the reference.
2: Then read the current thread and store the reference
3: Later read the operation again. If the operation-instance is the same,
it means that you have captured the right thread.
Then you use this Thread to create a stack trace. It can happen that the
stracktrace doesn't reflect the call-state the thread had when the slow
operation was detected. This could be solved by rechecking the currentTask
after you have detected the slow operation. BUt don't create a stacktrace
before you do the first recheck of the operation because otherwise it
will cause a lot of overhead.