Runs the given blocking task and returns the result.
If the current thread is not a WorkerThread, this method just runs the task without any further work. Otherwise, this method tries to create a new thread.
-> If succeed, the new thread takes the context of this thread and runs the remaining tasks in the context. This thread runs the blocking task and is marked as blocked until the task ends. After it ends, this thread is unblocked and takes the context back, and the new thread is terminated.
-> If failed, e.g. the maximum number of threads exceeded, this method just runs the function without any further work.
func |
a task function |
the result produced by the function |
Error |
the error thrown by the function |