O'Reilly logo

SFML Blueprints by Maxime Barbier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Thread functionality

Now, we will speak about threads. The threads' functionalities are very close to the fork ones, but with some important differences. A thread will create a new stream to your running process. Its starting point is a function that is specified as a parameter. A thread will also be executed in the same context as its parent. The main implication is that the memory is the same, but it's not the only one. If the parent process dies, all its threads will die too.

These two points can be a problem if you don't know how to deal with them. Let's take an example of the concurrent memory access.

Let's say that you have a global variable in your program named var. The main process will then create a thread. This thread will then write ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required