Synchronized Blocks Sometimes while working with third-party classes, we might want to synchronize the access to methods in those classes. In such cases, synchronized methods cannot be used. Instead we can use synchronized blocks. Syntax of a synchronized block is as follows: synchronized(object-reference) { //Statements to be synchronized } The above program can be modified to contain a synchronized block as shown below: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
The post What are synchronized blocks in java Programming appeared first on Coding Security.
What are synchronized blocks in java Programming
read more
Tidak ada komentar:
Posting Komentar