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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:12:16+00:00 2026-05-31T09:12:16+00:00

If I have a common thread pool that queues runnable tasks and the runnable

  • 0

If I have a common thread pool that queues runnable tasks and the runnable task is the same object every time.

What happens when it reaches a block of code (within the runnable task) that has a synchronised lock? and say 5 threads are waiting on the same lock?

When it unlocks, is the synchronised block a queue line waiting to be executed and new threads join the queue, or whoever managed to grab the block first?

If there isn’t a queue line, assuming I want an ordered execution, what is the best method to do so?

  • 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-31T09:12:18+00:00Added an answer on May 31, 2026 at 9:12 am

    synchronized blocks do not have any defined order. you can use a java.util.concurrent.locks.ReentrantLock with “fair” locking to achieve the same affect as a synchronized block, but with guaranteed ordering.

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

Sidebar

Related Questions

I'm writing a load-testing application in Java, and have a thread pool that executes
I have three tables of information where the business_id is the common thread. I
I have common functionality that I need to access from all screens of my
i have several common elements (components), that will generate some html. it seems my
I have a common code of serializing a class object in my 3-4 methods
I have a common comms library that i have written to communicate with our
I have a multithreaded .NET Windows Service that hangs intermittently -- maybe once every
What is the common theory behind thread communication? I have some primitive idea about
I have an ASP.NET webpage running under IIS that uses a common assembly that
There is a very common task I face again. I have already solved this

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.