blocking
Description:
Runs the given blocking task and returns the result.
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.
This method must be called in this thread.
Parameters:
func |
a task function |
Returns:
the result produced by the function |
Exceptions:
Error |
the error thrown by the function |