サンプル集 |
■VC ■C# ■Java ■BorlandC ■LinuxC ■MS-DOS ■bash ■Excel VBA ■VBScript ■PHP ■HTML ■perl ■iPhone ■Android ■Lua ■other |
Linuxコマンド |
用語集 |
debian メモ |
apache2 メモ |
MySQL メモ |
Oracle メモ |
HOME |
3つのスレッドを生成し、全てのスレッドの終了を待ちます。
◆環境OS | Linux 2.6.9-5.0.3.EL |
---|---|
gcc | 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) |
メインです。
LC004_main.c | ||
|
スレッドで動く関数です。 printfでメッセージを表示し3秒待ち、またメッセージを表示し終了します。
LC004_threadMain.c | ||
|
メイクファイルです。
makefile | ||
|
◆実行結果
$ ./LC004
LC004_main start!!
thread ID=[2305843009227354752]
thread ID=[2305843009237840512]
thread ID=[2305843009248326272]
My Thread start!![4]
My Thread start!![3]
My Thread start!![2]
My Thread end!![2]
My Thread end!![3]
My Thread end!![4]
LC004_main end!!
$ ./LC004
LC004_main start!!
thread ID=[2305843009227354752]
thread ID=[2305843009237840512]
thread ID=[2305843009248326272]
My Thread start!![0]
My Thread end!![0]
My Thread start!![3]
My Thread start!![1]
My Thread end!![1]
My Thread end!![3]
LC004_main end!!
LC004_main start!!
thread ID=[2305843009227354752]
thread ID=[2305843009237840512]
thread ID=[2305843009248326272]
My Thread start!![4]
My Thread start!![3]
My Thread start!![2]
My Thread end!![2]
My Thread end!![3]
My Thread end!![4]
LC004_main end!!
$ ./LC004
LC004_main start!!
thread ID=[2305843009227354752]
thread ID=[2305843009237840512]
thread ID=[2305843009248326272]
My Thread start!![0]
My Thread end!![0]
My Thread start!![3]
My Thread start!![1]
My Thread end!![1]
My Thread end!![3]
LC004_main end!!
Copyright (C) 2013 ymlib.com