Seltsame Reihenfolge der Ausführung von Threads in C ++

Ich habe versucht, das erste Beispiel von auszuführenLinux Tutorial Posix-Threads. Das habe ich:

<code>[alex@Allok c_c++]$ g++ -lpthread from.cpp
from.cpp: In function ‘int main()’:
from.cpp:10:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
from.cpp:11:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
[alex@Allok c_c++]$ ./a.out 
Thread 2 
Thread 1 
Thread 1 returns: 0
Thread 2 returns: 0
</code>

Das Problem ist, dass ich erwartet habe, dass die Ausgabe so ist, wie die Quelle sagt:

<code>Thread 1
Thread 2
Thread 1 returns: 0
Thread 2 returns: 0
</code>

Ich verstehe nicht, warum es passiert. Kann mir jemand helfen?

<code>[alex@Allok c_c++]$ uname -a
Linux Allok 3.3.2-1-ARCH #1 SMP PREEMPT Sat Apr 14 10:08:43 UTC 2012 i686 AMD Athlon(tm) II Neo K125 Processor AuthenticAMD GNU/Linux
</code>

Antworten auf die Frage(1)

Ihre Antwort auf die Frage