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

  • Home
  • SEARCH
  • 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 9111235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:27:23+00:00 2026-06-17T03:27:23+00:00

Note: I’m not looking for workarounds; I’m sure I can find other methods if

  • 0

Note: I’m not looking for workarounds; I’m sure I can find other methods if necessary. I simply feel like I’m missing something fundamental or quirky and I want to know what I’m missing. Or if there is a way to use the debugger to get more info that would be nice too. Thanks!

I’m having an issue with use of synchronized. I’m receiving deadlock but it seems utterly impossible. I’ve placed print statements before each and every synchronized call, just inside each call, and just before exiting so I can see who all holds which synchronized objects. I’m finding that it will not go inside one of my synchronized calls even though no one currently holds the lock on the object. Are there some kind of quirks that I’m missing or illegal nesting operations? Here’s the jist of what I am doing.

Oh yeah, and the oddest thing is that removing the two “busyFlagObject” synchronizations makes it work fine…

Thread 1:

public void DrawFunction()
{
    synchronized(drawObject)
    {
        ...
        // Hangs here though nobody has a lock on this object
        synchronized(animationObject)
        {

        }
    }
}

Thread 2:

public void AnotherFunction()
{
    synchronized(busyFlagObject)
    {
        // Calls a function that also uses this same Synchronized call
        synchronized(busyFlagObject)
        {
            // Calls another function that uses another Synchronized call
            // Hangs here waiting for the draw function to complete which it SHOULD 
            // be able to do no problem.
            synchronized(drawObject)
            {

            }

            // Never gets to this one assuming the Log statements don't 
            // buffer and aren't flushed but still shouldn't be a problem anyway.
            synchronized(animationObject)
            {

            }
        }
    }
}
  • 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-17T03:27:24+00:00Added an answer on June 17, 2026 at 3:27 am

    Run your app under the debugger or use “jstack” from the JDK tools. That will show you directly which threads wait for locks and which hold locks, so we don’t have to guess where your problem is 🙂

    That said, you mention you synchronize on Boolean. Keep in mind that the class is intended to only have two instances, and many things (particularly boxing) will implicitly change your Boolean instance to the “shared” value. Are you sure your lock objects are not the same instance? You might consider using new Object() as your monitor object.

    It’s worth noting that this isn’t the only place that this can happen and there’s a good entry on this problem in Java Concurrency in Practice, specifically with string interning, that I’m failing to find a link to at the moment. Don’t use a type that isn’t under your control as something it wasn’t intended to do 🙂

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

Sidebar

Related Questions

Note: Not sure if this is the right stack, please tell if I should
Note: this is NOT like this question I've been tasked to construct a survey
note, I am not asking for answers. I simply am curious regarding why things
Note This is not a REBOL-specific question. You can answer it in any language.
Note, this is not a duplicate of .prop() vs .attr() ; that question refers
(Note: This is not a question about what is the best way with code
Note: I am not asking how to use Google Code's SVN repo as a
Note: I understand this is not strictly about development, but in the earlier threads
NOTE: This is not a duplicate of VB.NET equivalent of C# property shorthand? .
Note: Script is not an option for me I am sending emails to customers

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.