Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4258692
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:41:01+00:00 2026-05-21T05:41:01+00:00

Ok, this might be a rather silly question, but what is the benefit of

  • 0

Ok, this might be a rather silly question, but what is the benefit of using parallel collections within an actor framework? That is, if I’m only dealing with one message at a time from an actor’s mailbox, is there even a need for a parallel collection? Are parallel collections and actors mutually exclusive? What is a use case that would involve both?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:41:01+00:00Added an answer on May 21, 2026 at 5:41 am

    They solve different problems . Actors are good at solving task parallel problems. While parallel collections are good at solving data parallel problems. I don’t think they are mutually exclusive – you can use parallel collections in actors and parallel collections containing actors.


    Edit – quick test:
    Even something simple like a actor notification loop benefits.

    In the following code we register a million actors with an actor registry which has to notify them of an event.

    The non-parallel notification loop ( registry foreach {} ) takes an average of 2.8 seconds on my machine (4 core 2.5 GHz notebook).
    When the parallel collection loop ( registry.par.foreach {} ) is used it takes 1.2 seconds and uses all four cores.

    import actors.Actor
    
    case class Register(actor: Actor)
    case class Unregister(actor: Actor)
    case class Message( contents: String )
    
    object ActorRegistry extends Actor{
      var registry: Set[Actor] = Set.empty
    
      def act() {
        loop{
          react{
            case reg: Register => register( reg.actor )
            case unreg: Unregister => unregister( unreg.actor )
            case message: Message => fire( message )
          }
        }
      }
    
      def register(reg: Actor) { registry += reg }
    
      def unregister(unreg: Actor) { registry -= unreg }
    
      def fire(msg: Message){
        val starttime = System.currentTimeMillis()
    
        registry.par.foreach { client => client ! msg } //swap registry foreach for single th
    
        val endtime = System.currentTimeMillis()
        println("elapsed: " + (endtime - starttime) + " ms")
      }
    }
    
    class Client(id: Long) extends Actor{
      var lastmsg = ""
      def act() {
        loop{
          react{
            case msg: Message => got(msg.contents)
          }
        }
      }
      def got(msg: String) {
        lastmsg = msg
      }
    }
    
    object Main extends App {
    
      ActorRegistry.start
      for (i <- 1 to 1000000) {
        var client = new Client(i)
        client.start
        ActorRegistry ! Register( client )
      }
    
      ActorRegistry ! Message("One")
    
      Thread.sleep(6000)
    
      ActorRegistry ! Message("Two")
    
      Thread.sleep(6000)
    
      ActorRegistry ! Message("Three")
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a silly question, but is there a webpage/document/book that gives you
This might be a silly question, but: Suppose an expression depends only on literals,
this might be a stupid question, but I'm using asp.net list control that creates
I'm not sure if this might be a rather stupid question. But is it
This might be a stupid question, but I notice that in a good number
This might sound like a trivial question, but it is rather important for consumer
This might be a silly and obvious question, but why are list access algorithm
This might at first glance seem rather similar to this question , but in
I rather expect that this might be impossible - but I was wonderring if
Know this might be rather basic, but I been trying to figure out how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.