Inter-thread communication in Java
Carvia Tech | August 05, 2019 | 1 min read | 27 views
Inter-thread communication is all about allowing threads to communicate with each other over a shared mutable object.
Java’s Object class provides 3 final methods which allows inter-thread communication:
All these methods must be used within a synchronized block only.
It instructs the calling thread to give up the lock and go to sleep until some other thread enters the same monitor and calls notify()
It wakes up a single thread that was in waiting state (because that thread called wait()) on the same object. Calling notify() does not actually give up a lock on a resource.
It functionality is quite similar to notify() except that it wakes up all the threads that were on waiting state on the same object.
Top articles in this category:
- Top 50 Multi-threading Java Interview Questions for Investment Bank
- Citibank Java developer interview questions
- Java Concurrency Interview Questions and Answers
- Morgan Stanley Investment Banking Java Interview Questions
- Sapient Global Market Java Interview Questions and Coding Exercise
- BlackRock Top Java Interview Questions: Investment Banking Domain
- Goldman Sachs Java Interview Questions for Senior Developer
Find more on this topic:
Interview - Product Companies, eCommerce Companies, Investment Banking, Healthcare Industry, Service Companies and Startups.
Last updated 1 week ago
Recommended books for interview preparation:
- Send GMAIL emails from Java and Spring
- Send Mandrill emails from Spring Boot in Java
- Top 30 Hibernate and Spring Data JPA interview questions
- Generating variable length secure key/secret in Java
- Reverse the bits of a number and check if the number is palindrome or not
- MD5 and SHA-256 in Java Kotlin and Android
- Spring Security 5 - There is no PasswordEncoder mapped for the id
- Inter-thread communication in Java
- What are different thread states in Java
- Static method synchronization aka Class Lock in Java
Enter your email address to subscribe to this blog and receive notifications of new posts by email.