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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:59:45+00:00 2026-05-24T13:59:45+00:00

I have read http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html I decide to make my lock uncancelable task by try

  • 0

I have read http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html

I decide to make my lock uncancelable task by

try {
    lockedRecords.wait();
} catch (InterruptedException e) {
    interrupted = true;
}

but is there a need to

} finally {
    if (interrupted) {
        Thread.currentThread().interrupt();
    }
}

The article says that you should call interrupt() to preserve the interrupted status. I’m still very blur, so what if I set .interrupt? what happens next? a bit lost on this.. any input?

What value does it bring to my program? Please kindly explain in layman terms, greatly appreciated 😀

  • 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-24T13:59:45+00:00Added an answer on May 24, 2026 at 1:59 pm

    What’s important here is the code that is not written in the example.
    The method in the example (getNextTask) could be used in:

    while (!Thread.interrupted()) {
       Task task = getNextTask(queue);  
       doSomething(task);
    }
    System.out.println("The thread was interrupted while processing tasks.");
    System.out.println("...stopped processing.");
    

    The while loop above executes forever, unless someone interrupts the thread on which this loop runs.

    If the interrupt status is not reset as is done in getNextTask however, when someone tries to interrupt the thread when the thread is in queue.take in getNextTask, then the interrupt is lost and the bit of code I wrote above will never stop looping.

    The whole point of the example on the IBM webpage is that you must be very careful when you swallow an interrupt since it might accidentally make a thread impossible to interrupt.

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

Sidebar

Related Questions

I have read the tutorial from ibm about xml parsing (http://www.ibm.com/developerworks/opensource/library/x-android/) In this example,there
I have read the tutorial from ibm about xml parsing (http://www.ibm.com/developerworks/opensource/library/x-android/) In this example,there
So, here is the discussion I have just read: http://www.mail-archive.com/delphi@delphi.org.nz/msg02315.html BeginUpdate and EndUpdate is
I have read the GOLD Homepage ( http://www.devincook.com/goldparser/ ) docs, FAQ and Wikipedia to
I have read the documentation ( http://dev.mysql.com/doc/refman/5.1/en/partitioning.html ), but I would like, in your
I read ( http://www.stereopsis.com/FPU.html ) mentioned in ( What is the fastest way to
Firstly, I have read these: (1) http://www.gaiagps.com/news/article/iOS5%20Breaks%20Data%20Storage%20and%20Crushes%20My%20Soul (2) http://iphoneincubator.com/blog/data-management/local-file-storage-in-ios-5 (I can not submit more
I have read these: Adding item to the Desktop context menu in Windows http://www.informit.com/articles/article.aspx?p=169474
I have read here http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5765d7a8-7722-4888-a970-ac39b33fd8ab that to instal .NET 4.0 CP (client profile) you
I've just read http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html?page=5 and it says: the compiler is free to assign a

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.