Java synchronisation is better option where we want to allow only one thread to access the shared resources.
the synchronisation is mainly used to
1. prevent thread interference
2. to prevent consistency problem.
Types of synchronisation:-
there are two types of thread synchronisation mainly exclusive and the inter thread communication.
1. Mutual exclusive
mutual exclusive help keep threads from interfering with one another while sharing documents this can be done by 3 ways in Java.
1. by synchronised method
2. by synchronised block
3.by static synchronisation.
#Java synchronised method:-
if you declare any method as a synchronised it is known as synchronised method.
0 comments:
Post a Comment