Hi I am writing a multithreads program.
I have a variable in the main thread,
can I use it at the child thread?
For example I have a count in main,
when the count reaches 10, I will execute some command at the child
is it OK?
Maybe, maybe not. You did not happen to mention which threading
package you are using: there are different ones with different rules.
Not much about threading is generally considered appropriate in
comp.lang.c though, as clc deals mostly with ANSI/ISO standard C,
and threading is not part of those standards per se.
If you are using POSIX threads then you may wish to look at
condition variables -- though there are other ways such as
semaphores, write locks, and mutexes. For the condition you describe,
a semaphore would perhaps be the most natural, but I can't tell
at the moment whether it is part of POSIX threads or a local extension
on the man page I am examining. And as to how you would proceed under
Windows or other versions of threading... well, best ask these questions
in a newsgroup more specific for your OS.