Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can store a single instance in a static field of a class that any number of threads can
waitupon. Where the instance is stored does not matter. The key is that all threads have access to the same instance–be it from a static field/method or a singleton service object or a static local variable.While this example uses the built-in Java
waitandnotifyAllmethods, you’re far better off using thejava.util.concurrentpackage rather than rolling your own multithreading solutions.