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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:33:47+00:00 2026-06-13T12:33:47+00:00

When make more fair to prevent starvation in java using lock instead of declare

  • 0
  1. When make more fair to prevent starvation in java using lock instead of declare synchronized function
    it can not instantiate the type Lock

  2. do it need to implement FairLock like http://tutorials.jenkov.com/java-concurrency/starvation-and-fairness.html
    do java’s lock equal FairLock above? It said FairLock will slow performance, what will it be in real practice

    Lock lock = new Lock();
    
  • 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-13T12:33:48+00:00Added an answer on June 13, 2026 at 12:33 pm

    You’re probably trying to instantiate a java.util.concurrent.locks.Lock, which is an interface. That won’t work of course. You’ll want to instantiate an implementation, such as ReentrantLock, which is pretty much the standard way of doing “flexible” locks in Java, in cases where simple monitor locks aren’t sufficient. Its documentation has something to say about fairness:

    The constructor for this class accepts an optional fairness parameter. When set true, under contention, locks favor granting access to the longest-waiting thread. Otherwise this lock does not guarantee any particular access order. Programs using fair locks accessed by many threads may display lower overall throughput (i.e., are slower; often much slower) than those using the default setting, but have smaller variances in times to obtain locks and guarantee lack of starvation. Note however, that fairness of locks does not guarantee fairness of thread scheduling. Thus, one of many threads using a fair lock may obtain it multiple times in succession while other active threads are not progressing and not currently holding the lock. Also note that the untimed tryLock method does not honor the fairness setting. It will succeed if the lock is available even if other threads are waiting.

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

Sidebar

Related Questions

I edited the question so it would make more sense. I have a function
I am not able to make more than one request at a time in
How can I make a terrain generator that makes more realistic terrain? My current
Is it acceptable to make more than 1 facade class (not instance) in a
I have the following tables. I wanted it so when I make more boxes
I am really trying to be a better programmer, and to make more modular,
To make this more clear, I'm going to put code samples: $file = fopen('filename.ext',
How to make one more eval merge ? <asp:HiddenField ID=HiddenField1 runat=server Value='<%# Eval(Name),Eval(Surname),Eval(Mail)%>'/>
I am editing the question to make it more specific. I want to run
I'm trying to reorganize my code and make it more unobstrusive. Mainly, there is

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.