avatar
z*c
1
Hi, dear all:
after forking several threads, the main thread needs to
wait for some
time interval to continue.
1: I can not use Sleep() since it will make all threads
sleep.
2: when I use delay(), it needs another function to convert
seconds into ticks.
but when I compile it , it seems the compiler can not
reference to these functions, do I have to link it with some
libraries?
3: In some examples, I saw something like
pthread_deley_np(), but I cannot
find with man in my unix machine.
a
avatar
t*q
2
Hi,
why do you need to wait the time?
can you use a global variable setted by main and resetted by
the
thread, polling by the main thread.
1, you can use your own defined global variable
2, you can do that is use pthread_mutex.
3, another way is to use pthread_condattr_init to
synchronize the threads.
Suppose you do not need precise time just need the thread to
initilized. I use Linux
I use linux can not find delay.
I think you have to link the lib file too seems.
This is a RT_linux near_POSIX a
avatar
b*e
3

I remember u can only fork child process. Threads are not
forked. So u can just use sleep in the main thread routine.
All done.

【在 z***c 的大作中提到】
: Hi, dear all:
: after forking several threads, the main thread needs to
: wait for some
: time interval to continue.
: 1: I can not use Sleep() since it will make all threads
: sleep.
: 2: when I use delay(), it needs another function to convert
: seconds into ticks.
: but when I compile it , it seems the compiler can not
: reference to these functions, do I have to link it with some

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。