Linux and Threads

Ray A. Akey rakey at cnetbbs.net
Fri Dec 17 06:30:33 GMT 1999


On Wednesday, December 15, 1999 10:08 AM, Daniel Beckham
<danbeck at mtginfo.com> wrote:
> Threads are very easy to use.  The only problems that arise are when two
> threads try to use the same global variable  at the same time.  You have
to
> consider use mutexes/sempahores to resolve locking and memory
> issues.   But, since a simple daemon like you are proposing wouldn't need
> to use a shared variable, you don't have to worry about those types of
issues.

You assume that it is a "simple daemon."  In fact, it is far from simple. :)

Mutexes are required and _are_ implemented in this project as more than one
worker thread will be updating the UI. I've figured that I will just
pthread_detach() all threads and keep a "numthreads" mutex-protected global
counter that is incremented and decremented when threads are created and
destroyed, respectively. This seems to be the best solution to my previous
dilemma..  At least then main() won't exit prematurely, while numthreads >
0.






More information about the KDevelop mailing list