answersLogoWhite

0


Best Answer

By using an Runnable and Thread object.

EX:

Runnable r = new Runnable() {

Thread t = new Thread() {

@Override

public void run() {

//place code for new thread here

}

};

@Override

public void run() {

t.start();

}

};

r.run();

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

When a method is declared as synchronized, it means that only one thread at a time will be allowed to enter and execute the code in that method. All others will need to wait their turn.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Threads are synchronized using the synchronize keyword and by use of wait and notify communications between one another

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How threads are synchronized in a java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is synchronize in java?

Synchronization is a feature by which only one thread can access a resource in a particular time of instance. No other thread can interrupt for that resource. In java to make our method synchronize we use synchronized keyword with that method. So Synchronization is just managing the resources among Threads. Vijai Shanker Just to add with the invent of Java 5 we have more option to write synchronized code in Java instead of using synchronized keyword we can use Lock Classes available in concurrency package.


Why do you use synchronized block in java?

A Synchronized block is a block of code enclosed by the {} braces that has a synchronized keyword before it. This block of code is similar to a synchronized method and only one thread can access it at a time.


How you make shared and synchronized variable in java thread?

A Variable that is shared as well as synchronized cannot be created in Java. These two terms are mutually exclusive and a variable that is synchronized in java cannot be shared and vice versa


What are the synchronized methods and synchronized statements in java?

Synchronized Methods are methods that have the keyword synchronized in the method signature. Synchronized statements are pieces of java code that are surrounded by brackets which have the keyword synchronized qualifying them. Both cases mean that - only one thread will be able to access the method or the statement that is synchronized


How does one get java synchronized?

The Java program needs to be synchronized. Doing so can be complicated, but can be done. The best way to synchronize would be using the website and walk through the steps.


In relation to Java what is a thread?

A Java Thread is a thread of execution in a Java Program. A Java Virtual Machine can have a single application running multiple threads, which is known as concurrency. Threads are what make the program run. Each thread has a different priority, and when the machine queue fills up, the threads are executed in the order of their priority.


What do you mean by multithread program in java?

A Program in Java that spawns multiple threads is called a multithreaded program in Java.


What does it mean that a vector is synchronized in Java?

It means that multiple threads can safely read/modify data from a vector at the same time. Attempting to do that with an unsynchronized data type - an ArrayList, for instance - could result in an exception being thrown, or incorrect data being stored.


Where can one find out how to implement threads using Java?

You can find out how to implement threads using Java through Stacker Overflow, Java Script Source, Java Code Geeks, Free Programming Resources and other websites. There are also tutorials on college sites as well as Youtube.


Where can one find information about Java threads?

There is a lot of information about Java threads. The local library has many books on this topic. Also, websites like Oracle and O'Reiley have information on this topic for the public.


What java interface must be implemented by all threads?

Runnable interface


What is synchronized object in java?

synchronisation means one resource should use one system at a time