Java Part-41 | Thread Synchronization and Messaging (Gujarati)
Synchronization:
Because multithreading introduces an asynchronous behavior to your programs, there must be a way for you to enforce synchronicity when you need it.
For example, if you want two threads to communicate and share a complicated data structure, such as a linked list, you need some way to ensure that they don’t conflict with each other.
That is, you must prevent one thread from writing data while another thread is in the middle of reading it.
For this purpose, Java implements an elegant twist on an age-old model of inter-process synchronization: the monitor.
The monitor is a control mechanism first defined by C.A.R. Hoare.
You can think of a monitor as a very small box that can hold only one thread.
Once a thread enters a monitor, all other threads must wait until that thread exits the monitor.
In this way, a monitor can be used to protect a shared asset from being manipulated by more than one thread at a time.
Messaging:
After you divide your program into separate threads, you need to define how they will communicate with each other.
When programming with most other languages, you must depend on the operating system to establish communication between threads.
isAlive() & join():
- isAlive( ) on the thread.
The isAlive( ) method returns true if the thread upon which it is called is still running. It returns false otherwise.
- join() method allows one thread to wait for the completion of another.
If t is a Thread object whose thread is currently executing, t.join(); causes the current thread to pause execution until t's thread terminates.
Follow me @
? http://www.raviroza.com/
✍️ https://raviroza.wordpress.com/
✍️ https://raviroza.blogspot.com/
✍️ https://www.facebook.com/ravi.oza.it
✍️ https://twitter.com/raviozaIT
? https://www.youtube.com/user/ravioza101
#RaviROza #Jdk #Java #Gujarati
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java Part-41 | Thread Synchronization and Messaging (Gujarati)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.