Summary

This lesson summarizes the concepts covered in this chapter.

We'll cover the following

Chapter summary

  • Only shared data can be shared; immutable is implicitly shared.

  • __gshared provides data sharing, as in C and C++ languages.

  • synchronized is for preventing other threads from intervening when a thread executes a certain piece of code.

  • A class can be defined as synchronized so that only one member function can be executed on a given object at a given time. In other words, a thread can execute a member function only if no other thread is executing a member function on the same object.

  • The core.atomic module enables safe data sharing that can be multiple times faster than synchronized.

  • The core.sync package includes many other concurrency primitives.


Get hands-on with 1200+ tech skills courses.