How to designate a thread pool for actors

后端 未结 3 1277
闹比i
闹比i 2020-12-14 22:03

I have an existing java/scala application using a global thread pool. I would like to start using actors in the project but would like everything in the app using the same

3条回答
  •  萌比男神i
    2020-12-14 22:48

    I believe you can do something like this:

    trait MyActor extends Actor {
      val pool = ... // git yer thread pool here
      override def scheduler = new SchedulerAdapter {
        def execute(block: => Unit) =
          pool.execute(new Runnable {
            def run() { block }
          })
      }
    } 
    

提交回复
热议问题