Question: I just got a Beagle Board and started working with Cloud9. Everything worked fine until I tried to integrate it with Github. 

I could git init because I "didn't have sudo permissions" on Cloud9. Therefore, I cloned a repo to use with Cloud9. **Now, however, it looks like the Beagle Board dependencies are no longer there.** I get this error:

![enter image description here](https://i.stack.imgur.com/Zar2r.png)

The code I'm trying to run (which gets the error) is:

```
var b = require("bonescript");
b.pinMode('USR0', b.OUTPUT);
b.digitalWrite('USR0', b.HIGH);

```

Answer: 
The purpose of `join` is to, essentially, wait for the thread to complete. So once `Child->join();` returns, your thread has completed. Of course, you could also do `Child->join()` in the destructor [or at some other point, just make sure it is called at some point]. 

Note that, the thread will start running at some point between the time it actually created, and the end of join. There is no way of telling when that will happen. If you have lots of threads already running on the system, the time will be distributed between all threads, and your thread may not run for several seconds. On the other hand, if there is a CPU sitting there "twiddling it's fingers", it could quite possibly start before the main thread is out of the `new std::thread(...)` construction [because `std::thread` won't return until the thread has been properly created, and some data is being stored in the thread object, so the thread may well have completed by the time you get to `Child->join()`. There is no way to tell which of these options it is without knowing what state the system is in.
> 
> Is the thread being executed when I call join() or is it being run
>  sometime between when create the thread and when I call join?
> 
> 
> 

The thread is executed (started) after you create the thread, depending on the available resources that might take some time. The `join()` method waits(blocks) until the thread has finished its work. 

A suggestion: i would not name the variable to the `Sync` object `This`, its confusing, since there exists the `this` keyword.

You can safely delete the `std::thread` object after calling `join()` in `Async::Inc()`, plus you don't need to store the reference as a member variable, it's only used in that function.

You might also take a look at the `<atomic>` header, `std::atomic<int>` or `std::atomic_int`.