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 858805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:35:29+00:00 2026-05-15T08:35:29+00:00

This question describes what actors are in actor programming. What are messages? How can

  • 0

This question describes what actors are in actor programming. What are messages? How can you avoid shared state if you send an object in a message (assuming objects exist in actor programming)?

  • 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-15T08:35:29+00:00Added an answer on May 15, 2026 at 8:35 am

    If we think actors are People, then messages are like … messages.

    Say a Boss want to square root of a list of numbers a, and don’t want to do all the calculating himeself. He can hire some Workers, and the Boss will know their Phone numbers.

    So the Boss will SMS each of the Workers, and tell them to “Find the square root of a_i; reply me at 555-1234 after you’ve done.”. This instruction is a message. The Boss will then wait for the Workers to finish.

     +------+  sqrt(i=0, a_i=9)         +------------+
     | Boss | ------------------------> | Worker 0   |
     +------+                           +------------+
           |   sqrt(i=1, a_i=16)        +------------+
           ‘--------------------------> | Worker 1   |
                                        +------------+
                                           ....
    

    After the Workers completed the computation, they will send an SMS back the Boss and report the results. This is also done in message passing.

     +------+   set_result(i=0, val=3)  +------------+
     | Boss | <------------------------ | Worker 0   |
     +------+                           +------------+
           ^  set_result(i=1, val=4)    +------------+
           ‘--------------------------- | Worker 1   |
                                        +------------+
                                           ....
    

    This sounds like Object-oriented programming, but there are no order to which when a message is sent or received — they are passed asynchronously. (However, within the actor themselves, messages are received and queued synchronously.)

    When written in code, it may be like

    actor Boss:
       receive('run'):
         worker_addrs = spawn_many(SqrtWorker, len(a))  # hire workers.
         for i, addr in enumerate(worker_addrs): 
            send(addr, 'sqrt', reply_addr=self, i=i, a_i=a[i])
    
       receive('set_value', i, val):
         a[i] = val
    
    actor SqrtWorker:
       receive('sqrt', reply_addr, i, a_i):
         send(reply_addr, 'set_value', i, sqrt(a_i))
         quit()
    

    There are no “shared states problem”, because a state cannot be shared without copying. In my example above, the elements of list a are copied to each worker. In fact, only the Boss knows the existence of a — this is a local state.

    Now what if we really want to make a shared? In actor model, we would convert them into a new actor, and the Phone number of this actor are sent to the Worker.

     +------+  sqrt(i=0, a_phoneNum=555-1111)  +----------+
     | Boss | -------------------------------> | Worker 0 |
     +------+                                  +----------+
    
                 +---+
                 | a |
                 +---+
    

    The Worker then ask the list actor for the required info (it is possible because the Boss has given the Phone number of a to the Worker.)

     +------+                                 +----------+
     | Boss |                                 | Worker 0 |
     +------+                                 +----------+
                                                   |
                 +---+                             |
                 | a | <---------------------------’
                 +---+             get(i=0)
    

    Some time later the list replies…

     +------+                                 +----------+
     | Boss |                                 | Worker 0 |
     +------+                                 +----------+
                                                   ^
                 +---+       list_val(i=0, val=9)  |
                 | a | ----------------------------’
                 +---+
    

    then the Worker can compute the square root after receiving the message list_val.

     +------+     set_result(i=0, val=3)      +----------+
     | Boss | <------------------------------ | Worker 0 |
     +------+                                 +----------+
    
                 +---+
                 | a |
                 +---+
    

    The Boss finally updates the shared state

     +------+                                 +----------+
     | Boss |                                 | Worker 0 |
     +------+                                 +----------+
        | set(i=0, val=3)                
        |        +---+ 
        ‘------> | a | 
                 +---+ 
    

    Will there be any problems accessing shared state like this? No — since messages received by a must be run synchronously, all read/write actions will be interfere with each other. Thus there are no need to mess with mutexes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question 1 describes a way how to show list of phone numbers and
This question describes how auto indent is ignored with empty lines, using his/her example:
This question describes my conclusion after researching available options for creating a headless Chrome
I'm not sure if my Title for this question entirely describes accurately enough what
This question: How to generate a random BigInteger describes a way to achieve the
I'm really hoping I can describe this question in an understandable way. This is
This page describes how I can use the code generator in javac to generate
Can I set up HTML/Email Templates in C# on ASP.NET? This question was asked
Title basically describes the question. I'm assuming if it comes out as an array
This question describes the problem I'm having, but I'm not aware of any dependencies

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.