Problems with the traditional model – race conditions and deadlocks

The problems start to appear when more than one resource gets involved. Consider, for example, a slightly modified version of the preceding program. In the previous example, we had to write the result of the computation into a file. Consider that, at the same time as doing the computations themselves, we need to keep track of what they're doing in a log file. This kind of practice can be useful in a real-world scenario for debugging purposes.

So, the plan is as follows. First, the entire input file is read into the program memory. In our current scenario, threads are heterogeneous, which means that they have different tasks to accomplish. Homogeneous threads are generally ...

Get Mastering Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.