UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Where is the synchronized method used in java?

Asked by Last Modified  

4 Answers

Learn Java

Follow 2
Answer

Please enter your answer

Private Online Java Training by Exp Software Engineer

synchronized means that in a multi threaded environment, an object having synchronized method(s)/block(s) does not let two threads to access the synchronized method(s)/block(s) of code at the same time. This means that one thread can't read while another thread updates it. The second thread will instead...
read more
synchronized means that in a multi threaded environment, an object having synchronized method(s)/block(s) does not let two threads to access the synchronized method(s)/block(s) of code at the same time. This means that one thread can't read while another thread updates it. The second thread will instead wait until the first thread completes its execution. read less
Comments

The synchronized method is used in java to lock an object for any shared resource.
Comments

Tutor

If we keep synchronized keyword in front of the method , that will allow only 1 thread at a time to execute that method. Its basically used in multi thread programming.
Comments

IT Professional Salesforce CRM trainer

When one thread is executing a synchronized method for an object, all other threads that invoke synchronized methods for the same object block until the first thread is done with the object.i.e at a time one thread can access shared variable. please refer following code example: class disp { ...
read more
When one thread is executing a synchronized method for an object, all other threads that invoke synchronized methods for the same object block until the first thread is done with the object.i.e at a time one thread can access shared variable. please refer following code example: class disp { void display(String nm) { System.out.print("Mr "); try{Thread.sleep(2000);}catch(Exception e){} System.out.print(nm); System.out.println(" Das"); } } class syn implements Runnable { disp ob; String s; syn(disp ob1,String s1) { ob=ob1;s=s1; Thread t=new Thread(this); t.start(); } public void run() { synchronized(ob) { ob.display(s); } } } class synmain { public static void main(String ars[]) { disp ob=new disp(); new syn(ob,"ram"); new syn(ob,"shyam"); new syn(ob,"Hari"); new syn(ob,"jadu"); new syn(ob,"Madhu"); } } read less
Comments

View 2 more Answers

Related Questions

Sir tell me some tips to code in java?
If you know C / C++ already, just try how will you able to achieve same examples in java. I prefer try to understand the fundamental of java and create small programs, then make the connectivity among them. Slowly build an application.
Nitinkumar
Why Java is not a Pure Object oriented Programming Language?
Bcoz java does not support - All predefined types are objects All operations performed on objects must be only through methods exposed at the objects.
Amit Kumar
0 0
9
Why do many software engineers not like Java?
Opinions on programming languages can vary, but some software engineers may express dissatisfaction with Java for reasons such as perceived verbosity, boilerplate code, and a slower pace of language evolution...
Guruprasad
0 0
5
What is a good foundation course for JAVA?
I will not prefer any programming language or technology instead, You can focus on Concept and Principles. Because when you say your a programmer you should be a programmer rather than saying Java programmer,...
Rajeev J

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons


Features Of Java
There is given many features of java. They are also known as java buzzwords. The Java Features given below are simple and easy to understand. i. Simple ii. Object-Oriented iii. Portable iv. Platform...

Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

Create Immutable Class
Snippet of an Immutable Class: package com.stringhr; /*Declare the class as 'final'. This would prevent any other class from extending it and hence from overriding any method from it which could modify...

Use of Service Locator Pattern
If we want to reuse the java code that should be the best approach w.r.t re-usability, maintanence and saving time to concentrate on our own businbess logic/requirement. In the similar approach many patterns...
M

Recommended Articles

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more