This is a question asked to one of my friends during an interview.
How do you know whether a thread is blocked inside a synchronized method, from another thread?
Can anybody please explain this using an example?
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.
Using
Thread.getState():Outside of a VM, you can use the
jstacktool to get full thread information for every thread, or connect to JMX and explore the Thread MBeans.