Back to Top

Sunday, 15 January 2012

JAVA : Describe synchronization in respect to multithreading.

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. synchronization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors. So, its the mechanism that ensures that only one thread is accessed the resources at a time.


How to achieve synchronization in java?

In java, synchronization can be achieved by using the 
synchronized keyword. 
It can be used in 2 ways.
1. on a method signature: We can declare synchronized keyword in method signature, therefore, that method will be thread safe in multi-threaded environment. That means, only, one thread at a time can access this method.
Below, method execute() is synchronized, so it is can be accessed by one thread at a time.
       
synchronized void execute(){
  // do something
}
       
2. Write synchronized block: Secondly, we can write a synchronized block, and that block will be synchronized.

synchronized(this){
  // do something
}


The above code, will lock the object itself, when this piece of code has been executed by a thread.

34 Responses to “ JAVA : Describe synchronization in respect to multithreading. ”

Naviya Nair said...
24 October 2016 at 15:01

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

Java Training Institutes in Chennai Java Training in Chennai


Naviya Nair said...
24 October 2016 at 15:28

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

Java Training Institutes in Chennai Java Training in Chennai


jazz said...
21 March 2017 at 16:26

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your..
Vmware Training in Chennai


venkatesh raghunath said...
2 July 2017 at 11:53

Very impressive blog, it is very easy to understand, i really enjoyed to read this. thanks for sharing, keep rocks.
Java Training in chennai | Java Training institute in velachery


Jordan Alexo said...
24 January 2018 at 13:58

Hi admin..,
I am the big follower of your blog. I read all your blog for gathering lot of informations. keep sharing more blogs..,
Regards,
Java training in Chennai|| J2ee training in Chennai


merlinmadonna said...
14 March 2018 at 14:22

Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating.
oracle training in chennai|| hadoop training in chennai


Jordan Alexo said...
4 April 2018 at 14:28

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
Regards,
hadoop training in chennai || selenium training in chennai





Dipanwita said...
10 August 2018 at 13:28

This is a most useful blog post. Will recommend it to all Java enthusiasts. java training in chennai


sudha P said...
25 October 2018 at 15:35

We are a group of volunteers and starting a new initiative in a community. Your blog provided us valuable information to work on.You have done a marvellous job!
Java training in Bangalore | Java training in Marathahalli | Java training in Bangalore | Java training in Btm layout

Java training in Bangalore | Java training in Marathahalli | Java training in Bangalore | Java training in Btm layout


johnsy sai said...
26 October 2018 at 16:37

This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
Online DevOps Certification Course - Gangboard


amala jst said...
26 October 2018 at 19:06

This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 

rpa online training |
rpa course in bangalore |
rpa training in bangalore |
rpa training institute in bangalore


Mouni yoga said...
27 October 2018 at 10:44

This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
python training in rajajinagar | Python training in bangalore | Python training in usa


Naga Manickam said...
29 October 2018 at 18:04

I love the blog. Great post. It is very true, people must learn how to learn before they can learn. lol i know it sounds funny but its very true. . .

Data Science course in Chennai | Best Data Science course in Chennai | Data science course in bangalore | Best Data Science course in Bangalore

Data science course in pune | Data Science Course institute in Pune | Data science online course | Online Data Science certification course-Gangboard

Data Science Interview questions and answers


Vignesh G said...
30 October 2018 at 15:37

I am really happy with your blog because your article is very unique and powerful for new reader.
Click here:
selenium training in chennai
selenium training in bangalore
selenium training in Pune
selenium training in pune
Selenium Online Training


Dwarakesh babu said...
2 November 2018 at 12:24

I’m planning to start my blog soon, but I’m a little lost on everything. Would you suggest starting with a free platform like Word Press or go for a paid option? There are so many choices out there that I’m completely confused. Any suggestions? Thanks a lot.



AWS Training in NewYork City | Amazon Web Services Training in Newyork City


AWS Training in London | Amazon Web Services Training in London, UK

Amazon Web Services Online Training in USA | AWS Online Course in USA


sathya shri said...
9 November 2018 at 14:25

Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
angularjs Training in bangalore

angularjs Training in bangalore

angularjs Training in chennai

automation anywhere online Training

angularjs interview questions and answers


gowthunan said...
17 November 2018 at 12:16

Greetings from Florida! I’m bored at work, so I decided to browse your site on my iPhone during lunch break
fire and safety course in chennai


Dwarakesh babu said...
26 November 2018 at 14:32

Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
No.1 AWS Training in Chennai | Amazon Web Services Training Institute in Chennai
Best AWS Amazon Web Services Training Course Institute in Bangalore | Amazon Web Services AWS Training in Bangalore with 100% placements
AWS Online Training and Certification | Online AWS Certification Training Course


sandy star said...
27 November 2018 at 14:29

Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.

Advanced AWS Online Training | Advanced Online AWS Certification Course - Gangboard
Best AWS Training in Chennai | Amazon Web Services Training Institute in Chennai Velachery, Tambaram, OMR
Advanced AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTMLA ,Marathahalli


Dharani M said...
7 December 2018 at 10:32

Great information


java training in Marathahalli

spring training in Marathahalli

java training institute in Marathahalli

spring and hibernate training in Marathahalli


anushri v said...
7 December 2018 at 10:59

I'm here representing the visitors and readers of your own website say many thanks for many remarkable
online Python training
python training in chennai


Inigo joseph said...
8 December 2018 at 11:11

Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read  about their market situation nowadays.
python training institute in marathahalli
python training institute in btm
Python training course in Chennai


mounika said...
8 December 2018 at 11:25

Nice post..
DOT NET training in btm

dot net training institute in btm

dot net course in btm

best dot net training institute in btm


pooja said...
13 December 2018 at 10:13

Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
Java training in Bangalore | Java training in Jaya nagar

Java training in Bangalore | Java training in Electronic city

Java training in Chennai | Java training institute in Chennai | Java course in Chennai

Java training in USA


isai 14 said...
14 December 2018 at 10:10

Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
Java training in Chennai | Java training institute in Chennai | Java course in Chennai

Java training in Bangalore | Java training institute in Bangalore | Java course in Bangalore

Java online training | Java Certification Online course-Gangboard

Java training in Pune


Jayamari R said...
14 December 2018 at 11:51

Really very nice blog information for this one and more technical skills are improve,i like that kind of post.

rpa training in chennai
rpa training in bangalore
rpa training in btm | rpa training in kalyan nagar | rpa training in electronic city | rpa training in chennai | rpa online training | rpa training in bangalore
rpa training in chennai


jeeva said...
14 December 2018 at 13:22

Really very nice blog information for this one and more technical skills are improve,i like that kind of post.

rpa training in chennai
rpa training in bangalore
rpa training in btm | rpa training in kalyan nagar | rpa training in electronic city | rpa training in chennai | rpa online training | rpa training in bangalore
rpa training in chennai


sheela said...
17 December 2018 at 11:12

Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
Best Devops training in sholinganallur
Devops training in velachery
Devops training in annanagar
Devops training in tambaram


jeyanthi said...
19 December 2018 at 20:13

Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
Data Science training in Chennai | Data Science Training Institute in Chennai | Data Science Course in Chennai
Data science training in Bangalore | Data Science Training institute in Bangalore
Data science training in pune | Data Science training institute in Pune
Data science online training | online Data Science certification Training-Gangboard
Data Science Interview questions and answers
Data Science Tutorial


UNKNOWN said...
12 January 2019 at 19:49

Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
Devops Training in bangalore
Digital Marketing Training in bangalore
Data Science Training in bangalore
Java Training in bangalore


SANDY said...
13 January 2019 at 09:20

Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
aws training in bangalore
RPA Training in bangalore
Python Training in bangalore
Selenium Training in bangalore
Hadoop Training in bangalore


VRITPROFESSIONALS said...
21 January 2019 at 15:48

Nice post. Thanks for sharing! I want people to know just how good this information is in your blog. It’s interesting content and Great work.

Thanks & Regards,
VRIT Professionals,
No.1 Leading Web Designing Training Institute In Chennai.

And also those who are looking for
Web Designing courses training institutes in Chennai
HTML courses training institutes in Chennai
CSS courses training institutes in Chennai
Bootstrap courses training institutes in Chennai
Photoshop courses training institutes in Chennai
PHP & Mysql courses training institutes in Chennai


Unknown said...
30 January 2019 at 12:33

Thank you for excellent article.

Please refer below if you are looking for best project center in coimbatore

final year projects in coimbatore
Spoken English Training in coimbatore
final year projects for CSE in coimbatore
final year projects for IT in coimbatore
final year projects for ECE in coimbatore
final year projects for EEE in coimbatore
final year projects for Mechanical in coimbatore
final year projects for Instrumentation in coimbatore


yashnit said...
20 February 2019 at 17:41

Thanks For Sharing The Information The Information shared Is Very Valuable Please Keep Updating Us Time Just Went On reading The Article Python Online Training Aws Online Course DataScience Online Course Devops Online Course


Post a Comment

Popular Posts

Subscribe via Email
Subscribe Java Interview Questions via Email
All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar
blog links Web Directory Academics Blogs