我尝试执行Linux Tutorial Posix Threads中的第一个示例。这就是我所拥有的:
[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
问题是我希望得到像消息来源所说的输出:
Thread 1
Thread 2
Thread 1 returns: 0
Thread 2 returns: 0
我不明白为什么会这样。谁能帮我?
[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