Java Fundamentals - Lesson 47 - Using the synchronized keyword

preview_player
Показать описание
Are you new to Java development? Do you want to know what to start with? This is a complete stream dedicated to you - the junior developer or future developer.

- Java OCP 11 certification
- Learn Java basics
- Find a junior java developer role

If your target is at least one of the above, then this lesson streaming is for you. Join!

Don't forget to follow me on Twitter @laurspilca or LinkedIn for more posts and discussions.

Рекомендации по теме
Комментарии
Автор

I already press the like button as soon as the video starts, because I just know it will be another great lesson! Thanks so much for your videos, they are invaluable!

lenkamoravcikova
Автор

Awesome as always, by watching just three initial lectures, learned a lot. One cool exercise to new people to practice initial 3 lectures, --> use two thread, one thread will print odd number and other will print even till 10 starting from 1 alternatively. Those who are learning for the first time can try this exercise. (asked to me in ORACLE SE interview).(eg, 1->T0, 2->T1,

rajan-ub
Автор

Thanks! @Lauentiu Is it possible to have a non-static but same lock-monitor in more than one class?

AliHassan-bzsk
Автор

Visualize with paint is really really helpful. Thank you.

sva
Автор

Thanks as always! I have a query.
Assume there are two classes that specify the same monitor. Assume a thread owns the lock-monitor defined in one class. Can another thread still obtain the lock-monitor defined by the second class considering that  both classes defines the same monitor and the thread didn't release the lock monitor in the first class?

AliHassan-bzsk
Автор

Thanks :)! I just have a question: When a thread acquires a lock, do the other threads that are candidates for that lock actually enter a blocked state or runnable state? If they do enter a blocked state, how do they automatically comes to runnable state when a thread releases the lock?

AliHassan-bzsk
Автор

I already have watched a few videos about synchronized keyword. But none of them covered or emphasized the concept of monitor in details. Thanks

harshitsen
Автор

Thanks :). I have a question.
Consider that a thread obtains the lock of a synchronized block and executes that block of instructions. During that time, can the JVM move that thread to the RUNNABLE state, or does it remain in the RUNNING state until the synchronized block is not completed ?

AliHassan-tyme
Автор

I am yet to listen to the full Java fundamentals stream. Just wanted to know if you have discussed about ThreadLocal ? Would like to hear it from you

sreejeshraj
Автор

Hi How can we ensure that those who want to enter the synchronization block enter in the order of their requests? which keyword do we need to use?

xy
Автор

Hi @Laurentiu. .Do u have any plan to cover how synchronization techniques works in microservices?.. maybe in the different series... because these concept might not work in multiple JVM I guess.

aniket
Автор

Hi, after thanks how can i practice on this well? anything out of frameworks just thinking and implementing

abdelhafeeznada
Автор

What if the class has two synchronized blocks, can two threads access the two blocks ? or the lock of the object must be freed by one thread first

abdullaelsayed
Автор

Hello! You mentioned the monitor should be able to "see" and "manage" the threads and the list, these are a bit obscure words for me, what really means "seeing" and "managing" in this context? The object has to be able to access the threads classes? Also, can't just Object be a good monitor, as it can maybe "see" anything? Thanks

alphapicturesentertainment
Автор

In our example, can we use an object other than our resource (bucket)?
An object that is just created for monitoring. Will our code work if we use that object as a monitor in all the threads in place of "bucket"?

ashishambre
Автор

How do we properly choose a monitor(on what basis), is it mandatory ?

SantoshkumarAndra