This lesson summarizes the concepts covered in this chapter.

We'll cover the following

Chapter summary

  • When threads do not depend on other threads, parallelism is preferred. Consider concurrency only when threads depend on operations of other threads.

  • Because concurrency by data sharing is hard to implement correctly, favor concurrency by message passing; this is the subject of this chapter.

  • spawn() and spawnLinked() start threads.

  • thisTid is the thread id of the current thread.

  • ownerTid is the thread id of the owner of the current thread.

  • send() and prioritySend() send messages.

  • receiveOnly(), receive(), and receiveTimeout() wait for messages.

  • Variant matches any type of message.

  • setMaxMailboxSize() limits the size of mailboxes.

  • register(), unregister(), and locate() allow referring to threads by name.

  • Exceptions may be thrown during message passing: MessageMismatch, OwnerTerminated, LinkTerminated, MailboxFull, and PriorityMessageException.

Get hands-on with 1000+ tech skills courses.