Answers.Body: <h1>Concurrent programming is easy, synchronisation is hard.</h1>
  <p>Have a look at this video for an alternative to synchronisation: <a href="https://www.youtube.com/watch?v=2yXtZ8x7TXw" rel="nofollow noreferrer">https://www.youtube.com/watch?v=2yXtZ8x7TXw</a></p>
  <h1>When you have to synchronize</h1>
  <p>Use easy (High level) synchronization. see:</p>
  <ul>
  <li>Scoop from Eiffel.</li>
  <li>Transactions</li>
  <li>Pipelines / message passing</li>
  <li>coroutines (for when you don't need parallelisation)</li>
  </ul>
  <p>See also no lock / zero lock structures: Most pipes that are thread safe use locking. Or are not thread safe, and expect the user to do the locking. However it is possible to get thread safe zero lock queues. There rely on a few atomic instructions. (I prefer the name minimal lock, because the atomic instructions do locking).</p>
  <h1>Only use low-level synchronization to implement high-level synchronisation.</h1>
  <p>If you need synchronisation, and if you do not have high-level synchronisation, then find a good library that implements high-level synchronisation, using the existing low-level synchronisation.</p>
  <p>Don't write it your self, except as an exercise (and do to it as an exercise, it is fun and you will learn a lot), as it is very hard and you will get it wrong.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-17T08:35:35.317Z
Answers.LastActivityDate: 2017-09-17T08:46:38.297Z
Answers.LastEditDate: 2020-06-18T08:36:57.023Z
Answers.UserDisplayName: ctrl-alt-delor
Answers.Body: <p>Since the OP asked about functional programming, so I would highly recommend you to read "<a href="https://www.packtpub.com/application-development/learning-concurrent-programming-scala" rel="nofollow noreferrer">Learning Concurrent Programming in Scala</a>" by Aleksandar Prokopec, (2014). All the examples for this book are <a href="https://github.com/concurrent-programming-in-scala/learning-examples" rel="nofollow noreferrer">available on GitHub</a> to give you some idea of the book before you purchase it. </p>
  
  <h2>C#</h2>
  
  <p>I would recommend you to read "<a href="https://rads.stackoverflow.com/amzn/click/0470495995" rel="nofollow noreferrer">Professional Parallel Programming with C#</a>" - its based on .Net 4.0 and I have no update about following editions (if any)</p>
  
  <h2>C++</h2>
  
  <p>I think <a href="https://www.elsevier.com/books/an-introduction-to-parallel-programming/pacheco/978-0-12-374260-5" rel="nofollow noreferrer">Pacheco's book</a> would be my recommendation for sure</p>
  
  <p>Best of luck!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-24T11:04:46.003Z
Answers.LastActivityDate: 2017-09-24T11:12:02.140Z
Answers.LastEditDate: 2017-09-24T11:12:02.140Z
Answers.UserDisplayName: Failed Scientist
Answers.Body: <p>I have no recommendations for the theory part but since you are asking for implementation advice as well, here we go.</p>
  
  <p>If you are looking to use C sharp (you haven't specified a specific language of choice) then, as a dot net guy myself, I would recommend you start your self learning on concurrent programming with .NET implementation of same at <a href="https://docs.microsoft.com/en-us/dotnet/standard/threading/threads-and-threading" rel="nofollow noreferrer">Threads and Threading</a>.</p>
  
  <p>The link provides with what you can (most of the things you have discussed can be done in C sharp Threads) and what you cannot do. </p>
  
  <p>If you wish to dig deep, there are no specific books on threads in C sharp, but you can use the reference book I used which contains detailed implementation notes on the same at <a href="http://a.co/1rrmkoI" rel="nofollow noreferrer">C sharp 70 483</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-17T12:09:33.460Z
Answers.Text: Thanks. Can you tell more about "I am doing something similar but with functional programming"? By "functional programming", do you mean some other languages than C#?
Answers.UserDisplayName: Tim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-17T13:03:48.153Z
Answers.Text: I do a lot of self learning too and most recently (since 3 days or so) I have started self learning functional programming and asking questions about books and stuff.
Answers.UserDisplayName: Jay
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-17T10:18:47.347Z
Answers.LastActivityDate: 2017-09-17T10:18:47.347Z
Answers.UserDisplayName: Jay
Answers.Body: <p>The <a href="https://www.manning.com/books/the-well-grounded-java-developer" rel="nofollow noreferrer">Well Grounded Java Developer</a> has an excellent section on concurrency. The author claims that <strong>very few</strong> developers correctly implement concurrency. As ctrl-alt-delor put it: concurrency is easy; synchronization is hard. </p>
  
  <p>In fact, avoiding errors from race conditions and unexpected asynchronous behavior is so difficult that the author recommends developers always use one of the Java 7 library features to implement multi-tasking.</p>
  
  <p>I have personally found debugging asynchronous code to be <strong>very</strong> hard. Errors just seem intractable and difficult to reproduce. While the libraries used in the book are Java specific, the reasons for needing those libraries are not.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-24T10:54:14.097Z
Answers.LastActivityDate: 2017-09-24T10:54:14.097Z
Answers.UserDisplayName: Thorn
Body: <p>I am self-learning concurrent programming. I have some experience with concurrent programming. Have self learned OS and programming. </p>
  
  <p>There are both programming languages and libraries that provide concurrent programming facilities. 
  I would like to learn about concurrent programming  at OS and library levels (e.g. multithreading, multiprocessing, spin locks, semaphore, ...) and language level (e.g. monitor, future, promise, channels, conditional critical regions, Coroutine, ...). For the specific topics,  I am referring to sections "Models",   "Prevalence" and "Languages supporting concurrent programming" in <a href="https://en.wikipedia.org/wiki/Concurrent_computing" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Concurrent_computing</a> and also <a href="https://en.wikipedia.org/wiki/Concurrency_pattern" rel="nofollow noreferrer">concurrency patterns</a>.</p>
  
  <p>I would like to learn at conceptual as well as specific language levels.</p>
  
  <ul>
  <li><p>Could you recommend some books which explain the different approaches at a concept level? It is good for such books to have  specific languages and libraries as examples, but not necessarily especially if the books you recommend are classic but not contemporary.</p></li>
  <li><p>Could you also recommend which specific languages and libraries and books on specific languages and libraries? For specific languages, I am currently interested in functional languages (such as Scala, Haskell, OCaml ...), Python, C#, Java, C/C++ and Go.</p></li>
  </ul>
  
  <p>Academic books (text books, survey) and professional/practical books are both welcome.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-17T12:50:30.450Z
Comments.Text: @Buffy: I value concepts as much as technical details in specific languages, because that will help me learn concurrent programming knowledge that can apply to all/most languages, without being lost in the differences between specific langauges. I am not sure if searches in specific languages will help me achieve that goal.
Comments.UserDisplayName: Tim
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-01T11:29:36.843Z
Comments.Text: My first book ever on this subject was "Concurrent C" - this is not a book about actual C, it suggests an extension to C, which would implement communicating-processes calculus. This book seems to have inspired Go authors, and, perhaps Erlang authors (not sure which came first, the book or the language). Clojure has implementation of CSP, though due to the difference in syntax the similarities aren't immediately apparent.
Comments.UserDisplayName: wvxvw
Tags: <resource-request><self-learning><textbook><concurrency>
Title: Could you recommend books on concurrent programming?
ThreadText: # Could you recommend books on concurrent programming?
  
  (Asked by: username_0 on 2017-09-16)
  
  I am self-learning concurrent programming. I have some experience with concurrent programming. Have self learned OS and programming.
  
  There are both programming languages and libraries that provide concurrent programming facilities.
  I would like to learn about concurrent programming at OS and library levels (e.g. multithreading, multiprocessing, spin locks, semaphore, ...) and language level (e.g. monitor, future, promise, channels, conditional critical regions, Coroutine, ...). For the specific topics, I am referring to sections "Models", "Prevalence" and "Languages supporting concurrent programming" in <https://en.wikipedia.org/wiki/Concurrent_computing> and also [concurrency patterns](https://en.wikipedia.org/wiki/Concurrency_pattern).
  
  I would like to learn at conceptual as well as specific language levels.
  
  * Could you recommend some books which explain the different approaches at a concept level? It is good for such books to have specific languages and libraries as examples, but not necessarily especially if the books you recommend are classic but not contemporary.
  * Could you also recommend which specific languages and libraries and books on specific languages and libraries? For specific languages, I am currently interested in functional languages (such as Scala, Haskell, OCaml ...), Python, C#, Java, C/C++ and Go.
  
  Academic books (text books, survey) and professional/practical books are both welcome.
  
  **Tags:** resource-request, self-learning, textbook, concurrency
  
  > **Comments:**
  > **username_0**: @Buffy: I value concepts as much as technical details in specific languages, because that will help me learn concurrent programming knowledge that can apply to all/most languages, without being lost in the differences between specific langauges. I am not sure if searches in specific languages will help me achieve that goal.  
  > **username_1**: My first book ever on this subject was "Concurrent C" - this is not a book about actual C, it suggests an extension to C, which would implement communicating-processes calculus. This book seems to have inspired Go authors, and, perhaps Erlang authors (not sure which came first, the book or the language). Clojure has implementation of CSP, though due to the difference in syntax the similarities aren't immediately apparent.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_2 on 2017-09-17. Score: 4
  
  # Concurrent programming is easy, synchronisation is hard.
  
  Have a look at this video for an alternative to synchronisation: <https://www.youtube.com/watch?v=2yXtZ8x7TXw>
  
  # When you have to synchronize
  
  Use easy (High level) synchronization. see:
  
  * Scoop from Eiffel.
  * Transactions
  * Pipelines / message passing
  * coroutines (for when you don't need parallelisation)
  
  See also no lock / zero lock structures: Most pipes that are thread safe use locking. Or are not thread safe, and expect the user to do the locking. However it is possible to get thread safe zero lock queues. There rely on a few atomic instructions. (I prefer the name minimal lock, because the atomic instructions do locking).
  
  # Only use low-level synchronization to implement high-level synchronisation.
  
  If you need synchronisation, and if you do not have high-level synchronisation, then find a good library that implements high-level synchronisation, using the existing low-level synchronisation.
  
  Don't write it your self, except as an exercise (and do to it as an exercise, it is fun and you will learn a lot), as it is very hard and you will get it wrong.
  
  
  ---
  
  ### Answer by username_3 on 2017-09-24. Score: 3
  
  Since the OP asked about functional programming, so I would highly recommend you to read "[Learning Concurrent Programming in Scala](https://www.packtpub.com/application-development/learning-concurrent-programming-scala)" by Aleksandar Prokopec, (2014). All the examples for this book are [available on GitHub](https://github.com/concurrent-programming-in-scala/learning-examples) to give you some idea of the book before you purchase it.
  
  ## C#
  
  I would recommend you to read "[Professional Parallel Programming with C#](https://rads.stackoverflow.com/amzn/click/0470495995)" - its based on .Net 4.0 and I have no update about following editions (if any)
  
  ## C++
  
  I think [Pacheco's book](https://www.elsevier.com/books/an-introduction-to-parallel-programming/pacheco/978-0-12-374260-5) would be my recommendation for sure
  
  Best of luck!
  
  
  ---
  
  ### Answer by username_4 on 2017-09-17. Score: 2
  
  I have no recommendations for the theory part but since you are asking for implementation advice as well, here we go.
  
  If you are looking to use C sharp (you haven't specified a specific language of choice) then, as a dot net guy myself, I would recommend you start your self learning on concurrent programming with .NET implementation of same at [Threads and Threading](https://docs.microsoft.com/en-us/dotnet/standard/threading/threads-and-threading).
  
  The link provides with what you can (most of the things you have discussed can be done in C sharp Threads) and what you cannot do.
  
  If you wish to dig deep, there are no specific books on threads in C sharp, but you can use the reference book I used which contains detailed implementation notes on the same at [C sharp 70 483](http://a.co/1rrmkoI)
  
  > **Comments:**
  > **username_0**: Thanks. Can you tell more about "I am doing something similar but with functional programming"? By "functional programming", do you mean some other languages than C#?  
  > **username_4**: I do a lot of self learning too and most recently (since 3 days or so) I have started self learning functional programming and asking questions about books and stuff.  
  
  ---
  
  ### Answer by username_5 on 2017-09-24. Score: 2
  
  The [Well Grounded Java Developer](https://www.manning.com/books/the-well-grounded-java-developer) has an excellent section on concurrency. The author claims that **very few** developers correctly implement concurrency. As username_2 put it: concurrency is easy; synchronization is hard.
  
  In fact, avoiding errors from race conditions and unexpected asynchronous behavior is so difficult that the author recommends developers always use one of the Java 7 library features to implement multi-tasking.
  
  I have personally found debugging asynchronous code to be **very** hard. Errors just seem intractable and difficult to reproduce. While the libraries used in the book are Java specific, the reasons for needing those libraries are not.
  
  
  ---
  
  