Akka control threadpool threads

后端 未结 2 1106
感情败类
感情败类 2021-01-16 16:07

Potentially a very silly question--

Is it possible to customize Akka/Scala actors such that you control the threads that are used by the actors? e.g. can you initial

2条回答
  •  感情败类
    2021-01-16 16:46

    I tried to understand it myself, but seams that guys in Akka don't want thread management to be exposed to public.

    ThreadPoolConfig - the class that is responsible for creation of ExecutorService instances is a case class with method createExecutorService() declared final!

      final def createExecutorService(threadFactory: ThreadFactory): ExecutorService = {
        flowHandler match {
          case Left(rejectHandler) ⇒
            val service = new ThreadPoolExecutor(...)
            service
          case Right(bounds) ⇒
            val service = new ThreadPoolExecutor(...)
            new BoundedExecutorDecorator(service, bounds)
        }
      }
    

    So, I don't see an easy ways to provide your own ExecutorService.

提交回复
热议问题