Wellll, you're really mixing different concepts here.
The reason to use react
instead of receive
is that each actor with a receive
requires its own thread. So you've got one thread per actor. react
on the other hand is handled by a pool of threads that will run that message on that actor and then go on to the next actor and message. (This really only permits you to be reactive--you can't wait for a certain amount of time.)
On the other hand, the Runnable
and Callable
interfaces are just ways to package up code in Java depending on whether you just want it to do stuff (Runnable
) or return a value (Callable
). The interfaces themselves don't have any difference in performance, but in order to get a Callable
return value back to you there is additional stuff that needs to happen, so if you could write it either way you'd possibly be better off using something that only requires a Runnable
. (In practice, this means starting a thread instead of a future, probably.) But the implementation details matter so much that you can't really make any general recommendations on the basis of the interface alone. You need to know how the interface is actually being used in the actual class you're calling.