Posts

Showing posts from May, 2019

Java Synchronized Keyword

The synchronized is a keyword defined in the java programming language. Keywords are basically reserved words which have specific meaning relevant to a compiler in java programming language likewise the synchronized keyword indicates the following :   ** The synchronized keyword may be applied to statement block or to a method. **  The synchronized keyword provides the protection for the crucial sections   that are required only to be executed by a single thread once at a time. **   The synchronized keyword avoids a critical code from being executed by more than one thread at a time. Its restricts other threads to concurrently access a resource. ** If   the synchronized keyword is applied to a static method, as we will show it with a class having a method SyncStaticMethod through an example below, the entire class get locked while the method under execution and control of a one thread at a time. **   When the synchronized keyword is applied to an instance method, as w