Topics…
- What to keep in mind when developing server
- When a function is:
- thread safe?
- synchronized?
- When multiple requests are hit on the server, how is it handled
- connection pool size
- What are the database considerations while developing the server?
- @Transaction??
Books and References
- https://docs.oracle.com/javase/tutorial/essential/concurrency/index.html
- https://github.com/preslavmihaylov/booknotes/tree/master/java/java-concurrency-in-practice/chapter-01
- Java Concurrency in practice by Joshua Bloch
- The art of multiprocessor programming by Maurice Herlihy
- https://www.youtube.com/playlist?list=PLBBK9G6O8MPDEeSVG17Pwya2xlUNbZn30 (Code with Ease by Varsha)
- Day to Day concurrency issues:
- Practice problems
Concurrency Interview Questions
- Design Bounded Blocking Queue
- Multithreaded Web Crawler
- Print Zero Even Odd
- Fizz Buzz Multithreaded
- The Dining Philosophers
Concurrency vs Parallel
- In Computer Science world they are different
- Concurrency is when the execution of multiple tasks is interleaved, instead of each task being executed sequentially one after another.
- Parallelism is when these tasks are actually being executed in parallel. For parallelism to happen, we need more than one cpu core. Hence Parallelism is limited by hardware.
- In scenario 1 (concurrency) green task is completed partially in two different steps in different time. Concurrent tasks look like they are executing in parallel.
- In scenario 2 (parallel), green task is completely executing in another processing unit and completely parallel to other tasks.

- https://stackoverflow.com/questions/4844637/what-is-the-difference-between-concurrency-parallelism-and-asynchronous-methods
- https://stackoverflow.com/questions/1050222/what-is-the-difference-between-concurrency-and-parallelism
- Tips:
- It’s not worth it to parallelize small tasks
- Do not parallelize infinite data source
- parallelism only benefits if we have multiple cores available
Sync vs Async
- An asynchronous method call is normally used for a process that needs to do work away from the current application and we don’t want to wait and block our application awaiting the response.
- Nodejs is asynchronous in nature and JS is single threaded language
Multithread vs Multicore vs Hyperthreading
- Thread is a software concept.
- A core can run multiple threads concurrently which will appear to be running in parallel but in reality it is switching between multiple threads very fast.
- Multicore is hardware concept. It refers to a processor that has more than one logical CPU core, and that can physically execute multiple instructions at the same time.
- Hyperthreading is a hardware concept according to which it means that the core can run two parallel threads, as if there were two cores.
- Hyperthreading increases the number of logical cores available
- https://stackoverflow.com/questions/11835046/multithreading-and-multicore-differences
Concurrency Models
- https://jenkov.com/tutorials/java-concurrency/concurrency-models.html
- Parallel Workers
- Assembly Line
- Functional Parallelism