Results 1 to 2 of 2
thread question... i have 2 threads.. 1 will execute and begin reading a file, when the thread encounters a space the thread will pause, at this point the second thread ...
- 09-20-2007 #1Just Joined!
- Join Date
- Sep 2007
- Posts
- 3
Pausing a thread
thread question... i have 2 threads.. 1 will execute and begin reading a file, when the thread encounters a space the thread will pause, at this point the second thread will begin executing.. this goes back and forth.. Anyways i am looking for a way of pausing the threads execution so the other thread can execute.. write now I:
....
pthread_cond_signal
pause by usleeping
...
..
this works fairly well for shorter files but eventually the timing gets a little bit off and some words get mixed up.
thanks
- 09-26-2007 #2
Quoth static_cast:
Raise your expectations! Either the synchronization between the two threads works perfectly, or the program's broken, in ways that can be really perplexing, expensive, and dangerous (in the real world) eventually. It's best to nail each timing problem aggressively!eventually the timing gets a little bit off
You don't want to pause by usleeping. You want pthread_cond_wait().
Hope this helps.


Reply With Quote