Get Hired

Jobs from Indeed

Sunday, March 25, 2018

Multithreading : Part 11 - Synchronization needed in real life



When there are many threads trying to access one shared resource, and are trying to fight over priorities, it isn’t good for your program. You might face inconsistency issues or unexpected thread interference.
To make sure a resource is being used by just one thread at a time, we make use of synchronization.
Just imagine this as a snack someone offers to you and your family when you visit their house. Each person in the room is a thread, and that delicious snack in the middle is a shared resource. Now wearing a mask of a good lad you are supposed to allow everyone to get a piece of it. That’s you and your siblings behaving in a synchronized way. That’s what synchronization in Java is about too.

No comments:

Post a Comment