answersLogoWhite

0


Best Answer

Of course. The synchronized keyword will ensure that only one thread will ever be allowed to execute a method at once. If two threads are attempting to access two different methods, then each method only has one thread executing it.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: If 2 different threads hit 2 different synchronized methods in an object at the same time will they both continue?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

What is deadlock in java?

A deadlock is a situation that comes up when multiple threads are being used in a single java program. During thread execution, threads can access any number of methods they want. To ensure that data is consistent during execution, the methods have a property called "synchronized" which prevents multiple threads from accessing a single method. So under this scenario lets take a look at this example: Thread A is currently holding a lock on Method A and needs to execute method B in order to complete. Thread B is currently holding a lock on Method B and needs to execute method A in order to complete. The above is a classic example of deadlock.


Different kind of threads in MFC?

There are two main kinds of threads implementations: User-space threads and Kernel-supported threads. Mikaela


How threads are synchronized in a java?

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();


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.


What is difference between synchronization and inter thread communication?

Synchronization is the process by which, access to the objects by threads are controlled and at at time only one thread can access an object. This is done to ensure that there are no dirty read/write operations. If multiple threads access the same data simultaneously, we may end up with inconsistent data. To avoid it, we place such code in synchronized blocks/methods to ensure integrity of data. Inter thread communication is the process by which java threads can communicate with one another. They communicate to one another through some commands like wait, notify, notifyall etc.


What is synchrronized keyword used for?

The synchronized keyword is one of the most important keywords that you may use while using Threads This will ensure that a particular object is accessed by only one thread at any given time


How do you synchronize java?

Synchronizaion is the process by which only one Thread can access an object at a time,until and unless thread releases it's lock no other thread can acess the object. there are two forms of syncronization method and statement.to make a method synchronized just add the keyword synchronized to the signature ie: public synchronized void increment() {c++;}to create syncrhonized statements are like this:synchronized(this) {lastName = name;nameCount++;}note: constructors can not be syncronized


What is ment by thread interaction in java?

Two threads can interact with one another using the wait and notify methods. If one thread wants another thread to wait until it completes, it can use the wait method. similarly if it wants the other threads to know that it is done executing, it can use the notify or notifyall methods


Which process cannot be used to produce external threads?

It cannot be produced by Milling machine...where it can be done by Forming and Rolling and turning methods..


Why oxford fabric different from other fabric?

Oxford cloth is commonly woven in basketweave (2 threads over/under two threads), and has a lustrous finish.


What do the colored threads represent in Gulliver's Travels?

In Gulliver's Travels, the colored threads represent the different political factions in Lilliput. Each thread corresponds to a different color and signifies a certain group. The threads are used to visually represent the division and conflicts within the society.


What resource are typically shared by all of the threads of a process?

There r some resources shared by different threads o the same process while some r not. The threads shares the address space,file,global variables. But each threads has its own stack , copy of registers(including PC).