answersLogoWhite

0


Best Answer

A Synchronized block is a block of code enclosed by the {} braces that has a synchronized keyword before it. This block of code is similar to a synchronized method and only one thread can access it at a time.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

Synchronized blocks are pieces of java code that are surrounded by brackets which have the keyword synchronized qualifying them.

It means that - only one thread will be able to access the block that is synchronized

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Java synchronized is a new program released by java and it's used for synchronizing different kind of programs that use java together in your computer.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why do you use synchronized block in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How you make shared and synchronized variable in java thread?

A Variable that is shared as well as synchronized cannot be created in Java. These two terms are mutually exclusive and a variable that is synchronized in java cannot be shared and vice versa


What are the synchronized methods and synchronized statements in java?

Synchronized Methods are methods that have the keyword synchronized in the method signature. Synchronized statements are pieces of java code that are surrounded by brackets which have the keyword synchronized qualifying them. Both cases mean that - only one thread will be able to access the method or the statement that is synchronized


What is synchronized object in java?

synchronisation means one resource should use one system at a time


How does one get java synchronized?

The Java program needs to be synchronized. Doing so can be complicated, but can be done. The best way to synchronize would be using the website and walk through the steps.


What is synchronize in java?

Synchronization is a feature by which only one thread can access a resource in a particular time of instance. No other thread can interrupt for that resource. In java to make our method synchronize we use synchronized keyword with that method. So Synchronization is just managing the resources among Threads. Vijai Shanker Just to add with the invent of Java 5 we have more option to write synchronized code in Java instead of using synchronized keyword we can use Lock Classes available in concurrency package.


What is the use of catch block in java?

the catch block catches the exception from the try block to display a proper message about the exception. Answered by, SOORAJ.M.S


How you use if condition in java?

The if block is used in java to check a true or false condition. for ex: if(age > 18) { system.out.println("You are an Adult"); } else { system.out.println("Sorry, you are still a kid"); }


What are block of statements in java?

In computer programming, a block or code block is a lexical structure of source code which is grouped together. In Java it is sed in the same way: to group code and separate it from the rest.


What is the purpose of synchronization?

Purpose of synchronization block is to lock an object for any shared resource. Scope of synchronized block is smaller than the method.


Can a method be static and synchronized?

Yes. In Java methods can be static and synchronized. Static methods access other static members in the class. Static in case of inheritance are treated as non - static. Synchronized methods are those which have dedicated thread attached to it and no other can access until currrent thread leaves the control from it.


Why use catch keyword in java?

no, because catch is used to handle exceptions which are generated from try block


Why use throw in java in compare try-catch?

we use throws in our program so that we dont need to write try & catch block & to avoid the exception