How does Actors work compared to threads?

前端 未结 2 584
悲哀的现实
悲哀的现实 2020-12-12 10:21

Is there any good and short explanation of how Actors works compared to threads?

Can\'t a thread be seen as an actor and send messages to other threads? I s

2条回答
  •  情深已故
    2020-12-12 11:07

    I wouldn't say that actors always pass messages asynchronously--that would be too slow. Case in point, the JActor project uses 2-way messages (request/response) to better model a method call. And most requests are serviced synchronously.

    JActor (a Java library) also does not use locks. Only some atomic and concurrent data structures, with a few semaphores thrown in. Message passing is about .8 Billion messages per second.

    https://github.com/laforge49/JActor

提交回复
热议问题