recategorized by
5,997 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

2 votes
2 votes
1 answer
1
makhdoom ghaya asked Jul 28, 2016
1,413 views
Which method is called first by an applet program ? start( ) run( ) init( ) begin( )
1 votes
1 votes
1 answer
2
makhdoom ghaya asked Jul 28, 2016
2,631 views
Converting a primitive type data into its corresponding wrapper class object instance is called BoxingWrapping InstantiationAutoboxing
1 votes
1 votes
2 answers
3
makhdoom ghaya asked Jul 11, 2016
1,819 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...