When does an actor not fit?

I use participants when I need to run two threads at the same time. I never use streams explicitly.

someone told me that the actors are pretty heavy and not always good to use.

  • What are the right scenarios for using actors and when not to use them?

  • Some of my actors just have a loop, but they don’t respond. Is this a good practice?

[EDIT]

  • Is it wrong to use Thread.sleep inside an actor loop?
+5
source share
4 answers

Actors provide a distributed asynchronous algorithm with a message passing model with computation and are most suitable for tasks corresponding to this model.

Scala , , , , . , .

. Distributed Computing .

, :

  • ,

    -, - . - .

    , , , , , .

  • ,

    , , .

    "" .

    , fork/join . Scala 2.9 , .

+10

, , , , :

new Thread(work1).start()
new Thread(work2).start()

. , , , , . , , , , , , .

, ForkJoin, Scala actor, . , (, ) /

+3

, , Actors , . - , " " , , .

, Actor , . () . , -.

0

@Jus12 - , , Akka IO. -, , , . , Akka IO, / ; , "" -.

Testing these participants is very simple. Use AkkaTestKit and make sure that each actor is expected to have a very simple set of inputs.

In many cases, the overhead of using the Akka library is more than paid to reduce the maintenance of your application.

0
source

All Articles