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 467873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:37:32+00:00 2026-05-12T23:37:32+00:00

For some reason, the output of this: public void msgNeedParts() { // Blabla… System.out.println(name

  • 0

For some reason, the output of this:

 public void msgNeedParts() {
    // Blabla...
    System.out.println(name + ": Try to print 'tasks'...");
    synchronized(tasks) {
        System.out.println(name + ": Tasks--" + tasks);
        System.out.println(name + ": Did I manage to print it?");
        tasks.add(new BinToDump(feeder, binNum));
    }
    stateChanged();
 }

Just prints out “GantryAgent: Try to print ‘tasks’…” but not any of the following messages. I’m guessing the thread somehow ‘gets stuck’ when trying to access the synchronized list ‘tasks’, but I don’t know why this is happening.

‘tasks’ was declared and initialized like this:

private List<BinToDump> tasks = 
    Collections.synchronizedList(new ArrayList<BinToDump>());

Can anybody point out what I’m missing?

Ah! I suspect I may have a culprit:

    /* If nothing left to do, return to original position. */

    synchronized (tasks) {

        if (tasks.isEmpty()) {

            doReturnToOriginalPos();

        }

    }

In my scheduler (this is an agent design), I check to see if ‘tasks’ is empty, then I call doReturnToOriginalPos(). Maybe this is just happening over and over so fast that other methods don’t get a chance to modify it?

That was indeed the problem! It kept getting called so fast in my scheduler that nothing else could access ‘tasks’. Thanks all for the help!

  • 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-05-12T23:37:32+00:00Added an answer on May 12, 2026 at 11:37 pm

    Something has a lock on tasks. Depending on what sort of application this is, you should be able to get a full stack dump of the system, but the method varies. For example, I think CTRL-Break on most windows-based appservers will do this, and I think sending a SIGQUIT on linux will do the same.

    Once you get a stack dump, you can look through it to try and find out which other thread has a lock on that object.

    You can also use VisualVM to get a stack dump, for the same end goal:

    You can use Java VisualVM to take a
    thread dump (stack trace) while a
    local application is running. Taking a
    thread dump does not stop the
    application. When you print the thread
    dump you get a printout of the thread
    stack that includes thread states for
    the Java threads.

    When you print a thread dump in Java
    VisualVM, the tool prints a stack
    trace of the active threads of the
    application. Using Java VisualVM to
    take a thread dump can be very
    convenient in cases where you do not
    have a command-line console for the
    application. You can use a stack trace
    to help diagnose a number of issues
    such as deadlocks or when an
    application hangs.

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

Sidebar

Related Questions

For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
for some reason when I try to call CocoaAsyncSocket's onSocket:didReadData:withTag method, it's failing and
For some reason this isn't working, am I missing something obvious? RewriteRule ^(.*)infopopup.html$ /acatalog/infopopup.html
I wrote this HttpRequest method, but for some reason it always goes to 404
For some reason this code results in a truncated text.txt file. It should (according
For some reason, whenever I try to copy over a database from my assets
This should be pretty simple but for some reason, I can't get this program
For some reason I can't detect I can't set a z index for any
For some reason there's a variable called d that is defined immediately after I
For some reason the postback event keeps firing for my button. If I place

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.