Reputation: 229
The parameters of beforeExecute()
in ThreadPoolExecutor
class are Thread and Runnable.
Sometimes we may need to override this method to satisfied our needs.
However, when I submit some callable tasks in executor. Here, in the beforeExecute()
we can only get Runnable
object, so I wonder if the executor convert the callable form to runnable implicitly???
I find some utility methods in Executors
class, which convert Runnable
to Callable
, but I don't find the opposite.
Upvotes: 2
Views: 378
Reputation: 692181
Calling submit(Callable)
calls newTaskFor()
, which returns a Runnable calling the Callable. And that Runnable is then passed to execute()
.
Upvotes: 5