question on Thread synchronization

Answers were Sorted based on User's Feedback



question on Thread synchronization..

Answer / rajani nagandla

With respect to multithreading, Synchronization is a
process of controlling the access of shared resources by
the multiple threads in such a manner that only one thread
can access a particular resource at a time. In non
synchronized multithreaded application, it is possible for
one thread to modify a shared object while another thread
is in the process of using or updating the object's value.
Synchronization prevents such type of data corruption which
may otherwise lead to dirty reads and significant errors.
E.g. synchronizing a function:
public synchronized void Method1 () {
// method code.
}
E.g. synchronizing a block of code inside a function:
public Method2 (){
synchronized (this) {
// synchronized code here.
}
}

Is This Answer Correct ?    10 Yes 3 No

question on Thread synchronization..

Answer / jitu

Synchronization is a
process of controlling the access of shared resources by
the multiple threads in such a manner that only one thread
can access a particular resource at a time.

Is This Answer Correct ?    5 Yes 0 No

question on Thread synchronization..

Answer / dayanand pujer (from gokak)

Threads commonly share the same memory space area, that’s
why they can share the resources. Threads commonly
communicate by sharing access to fields and the objects
reference fields refer to. This communication type is
extremely efficient, but makes two kinds of problems: thread
interference and memory consistency errors. By the
synchronization tool we can avoid this problem. In other
words, There is very critical situation where we want only
one thread at a time has to access a shared resources. For
example, suppose two people each have a checkbook for a
single account same as like two different threads are
accessing the same account data.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is jit and its use?

0 Answers  


if arraylist size is increased from initial size what is the size of arraylist...suppose initial is 100 , if i add 101 element what is the size...

10 Answers  


To the class members how can we provide security?

1 Answers   Aspire,


Why do we need array in java?

0 Answers  


When do I need to use reflection feature in java?

0 Answers  






What a static class can contains?

0 Answers  


What is jdbc api?

0 Answers  


What are advantages and disadvantages of OOPs?

0 Answers   Amdocs,


What is Difference between Serializable and Externalizable in Java serialization?

1 Answers   Cognizant, IBM,


What is JDBC Driver interface?How can you retrieve data from the ResultSet

0 Answers   CTS,


What are listeners in java and explain ?

2 Answers   TCS,


what are the uses of Class class and what it returns? explain it with the example code.

1 Answers  


Categories