Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8667439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:57:49+00:00 2026-06-12T17:57:49+00:00

I have a question on normal java threading theory. Thread A has taken a

  • 0

I have a question on normal java threading theory.

Thread A has taken a lock on some object, let say xObj. Now how does Thread B know that Thread A has already taken a lock on object xObj.

How this has been implemented in java.

Thanks in advance.

Thanks for your answers….Here i would like to clear that…I don’t have to implement this.My concern is How Java has implemented that.How Thread B will get to know that someone has already taken a lock on Object.May be Object class or some other class has implemented this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:57:50+00:00Added an answer on June 12, 2026 at 5:57 pm

    Thread A has taken a lock on some object, let say xObj. Now how does Thread B know that Thread A has already taken a lock on object xObj.

    It depends on the kind of lock you are talking about.

    • For a primitive mutex, one thread cannot test if another thread holds the mutex, let alone find out which thread it is. (It can test if holds the lock however …)

    • The Lock interface similarly doesn’t support this.

    • The ReentrantLock class does provide a method to find this out: see ReentrantLock.getOwner(). Note however that this is a protected method, so you’d need to create a subclass of ReentrantLock if you wanted to make the method generally available.


    I would also question the value of such a method. It can only tell you which (if any) thread owns the lock at the instant that the call was made. An instant later, the owner could have changed.

    By constrast, Thread.holdsLock() gives you information that you can rely on … albeit that it is information that isn’t useful under most circumstances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question. I have some app on facebook and getting this error Fatal
I have a Timestamp object- java.sql.Timestamp time = null; and I have a datetime
I have a MySQL table for persistence of some Java objects and use Hibernate
There is a Java Struts application running on Tomcat, that have some memory errors.
Question about the m2 eclipse plugin. Currently I have Eclipse Java EE IDE for
I have a java application (jar file) and I want to add some sort
So I'm learning java, and I have a question. It seems that the types
Sorry, I'm new to Java, so this question might be unclear. I have been
Please have a look at the following code package normal; import java.io.*; import java.util.*;
I have some java components that sometimes die and the only way I know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.