recategorized by
6,145 views

2 Answers

1 votes
1 votes

ans is B 

With respect to multi-threading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one Java thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to erroneous behavior or program.

1 votes
1 votes
answer is B

Synchronized methods enable a simple strategy for preventing thread interference and memory consistency errors. The following things can occur due to this:
1. If an object is visible to more than one thread, all reads or writes to that object's variables are done through synchronized methods.
2. It is not possible for two instances of synchronized methods on the same object to interleave. When one thread is executing a synchronized method for an object then other threads or methods block itself once the process of first thread execution is finished.
3. On the exit of synchronized method, it automatically creates a happens-before relationship with any other instance running of a synchronized method for the same object. This allow the changes to the state of the object that are visible to all threads.
Answer:

Related questions

1.5k
views
1 answers
2 votes
makhdoom ghaya asked Jul 28, 2016
1,528 views
Which method is called first by an applet program ? start( ) run( ) init( ) begin( )
2.8k
views
1 answers
1 votes
makhdoom ghaya asked Jul 28, 2016
2,769 views
Converting a primitive type data into its corresponding wrapper class object instance is called BoxingWrapping InstantiationAutoboxing
1.9k
views
2 answers
1 votes
makhdoom ghaya asked Jul 11, 2016
1,943 views
Match the following interfaces of Java. Servlet package $:$\begin{array}{clcl} & \textbf{List - I} && \textbf{List - II}\\ \text{a.}& \text{Servlet config} & \text{i} & \text{Enables ... -ii, b-iii, c-iv, d-i}$\text{a-iv, b-i, c-ii, d-iii}$
4.3k
views
3 answers
1 votes
Pooja Khatri asked Jul 13, 2018
4,344 views
What is the output of the following JAVA program?class simple { public static void main(String[ ] args) { simple obj = new simple(); obj.start(); } void start() { long [] P ... R) { R[1] = 7; return R; } } //end of class12:1515:1212:1215:15