Ordering Multiple Threads Using Intrinsic Lock


Saurabh Chopra

In this blog, I would like to demonstrate how to order multiple threads using Intrinsic lock(i.e. using synchronize key word).

Like we have 3 operations to perform and that too in the  same order in which we have started them. For this you have to declare three atomic boolean flags which will help them to run in the same order in which we want them to run and let other threads wait.

Reason to use Atomic boolean flag is to share them between all the threads.

Implementation for operation A:
 For the above code we have to check if operation A flag value is true or not. If it is true then we will perform the operation and set the flag value to be false and update the value of operation B flag to true and notify all the threads to perform. And if operation A flag value is falseā€¦

View original post 121 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s