global variable 'temp';
**threadA**
-pthread_mutex_lock-
if (temp == 'x')
-pthread_cond_wait-
do this
-pthread_mutex_unlock-
**threadB**
-pthread_mutex_lock-
if (someCondition == true)
temp = 'x'
-pthread_cond_signal-
-pthread_mutex_unlock-
私の場合、ループはなく、if 条件があるだけです。したがって、temp == 'x' の場合、threadA はそれ/これを行う必要があります。
- を扱う場合、ループは必須
pthread_cond_wait
ですか? - ループが必要ない場合、コードを書く他の方法は何ですか?
- これは正しいコードの書き方ですか?