CTM: Exercise 4-6
Posted by Urban Hafner
The problem
Thread scheduling. Section 4.8.3.2 shows how to skip over already-calculated elements of a stream. If we use this technique to sum the elements of the integer stream in section 4.3.1, the result is much smaller than 11249925000, which is the sum of the integers in the stream. Why is it so much smaller? Explain this result in terms of thread scheduling.
My solution
What probably happens is that generating another element in the production thread is so fast that more than one ca be generated in one time slice. When the consumer thread restarts in the next slice it only takes the last element computed, so it loses some (or many) elements.

