AdSense

Friday 27 September 2013

Raspberry PI - C++ - Threads

(Deutsche Version) Implementing threads in C# is pretty simple. To use threads with C++ on a Raspberry PI, you have to do some small things which are not necessary in C#. You have to place #include <thread> on the top. Then you can create a thread like this:

std::thread networkThread (networkCommunication);
networkThread.detach();


To compile this program, you have to add two things to the compile command in the terminal:

-std=c++0x
-pthread


The whole program is compiled like this:

g++ ./myProgram.c++ -o outputName -std=c++0x -pthread

Now you should be able to create threads on your Raspberry PI.

No comments:

Post a Comment