in reply to Re^15: Threads sharing global variable (disingenous)
in thread Threads sharing global variable

I am so sorry! In a previous node, when I asserted

The threads cannot both hold the lock. One must sit in cond_wait() while the other is working.
... I assumed that a native speaker would be able to correctly read this in context of the discussion thread. My message was not that a program may not have concurrently executing threads. Goodness gracious, no. The implication was that the sample code, as presented by ikegami, cannot have two of its lock-protected sections executing in parallel. Both while loops are protected (with the sole exclusion of an internal region inside the cond_wait() routine).

In retrospect, I may have made a misjudgment, especially in light of the misspelled /disingenous/ in the title.

Replies are listed 'Best First'.
Re^17: Threads sharing global variable (disingenous)
by BrowserUk (Patriarch) on Mar 09, 2016 at 22:55 UTC
    The implication was that the sample code, as presented by ikegami, cannot have two of its lock-protected sections executing in parallel.

    Exactly so! That is exactly why it is broken! So what point are you trying to make? (Don't bother to answer that.)

    What is the use of having two threads, and then constraining them to run alternately, one at a time, in lock step?

    It's a nonsense. It makes no sense. It is fatuous, pointless, and broken.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.