
27 Jul
2010
27 Jul
'10
10:59 p.m.
this approach is incorrect, look what can happen if for example the jobs container has last job to do:
thread A performs the check jobs.empty() and it pass, before the thread A executes the job.front() another thread B does the check jobs.empty() and it pass as well, then thread A does the jobs.front() and then when thread B does a jobs.front() as well.
Thanks Gaetano and others for the helpful comments. I have working thread safe code now using boost threads. I learned a lot from your feedback. You are right, threads are subtle and require careful thought and attention. _________________________________________________________________ Hotmail: Free, trusted and rich email service. https://signup.live.com/signup.aspx?id=60969