How can you tell if a thread can't get a lock on an object immediately?

A thread wishes to synchronize on an object called obj. When it hits the line
synchronized (obj)
it has to wait as another thread holds the lock.
I want some code to behave differently if it cannot get the lock immediately. Is there a way to tell if the thread is going to have to wait for the lock?
many thanks

Using just the language-level synchronization feature, you can't do it.
Look at the classes in the java.util.concurrent packages. I think there's something that will do that. If you're not on 1.5 yet, google for something like java concurrency library.

Similar Messages

  • I forgot my ipad password and my ipad is bloked, can you tell me what i can do

    i forgot my ipad password and my ipad is bloked, can you tell me what i can do

    There is only one solution.  You will have to restore your iPad via your computer in iTunes.  Do not restore from backup as you can't remember your password.  You'll have to restore as a new device and resync everything all over again.  Next time, write your password down for future reference.

  • My computer temp runs at 120 degrees. I used scmfancontrol but it did not lower the temp much. Can you tell me what I can do to make it work or any other suggestions to fix this would be most appreciated.

    My computer temp runs at 120 degrees. I used scmfancontrol but it did not lower the temp much. Can you tell me what I can do to make it work or any other suggestions to fix this would be most appreciated.

    To get rid of "pop-up ads and other crap on my computer when I am on the internet", click on Safari in the Menu bar, and select Preferences. Next select Extensions. Delete all of them. Restart Safari.
    The first step in addressing the black screen is an SMC reset.
    Shut down the computer.
    Plug in the MagSafe power adapter to a power source, connecting it to the Mac if its not already connected.
    On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
    Release all the keys and the power button at the same time.
    Press the power button to turn on the computer. 
    Note: The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.
    Excerpt from
    http://support.apple.com/kb/ht39

  • Can you tell me where I can find the exercise files for Dreamweaver

    can you tell me where I find the exercise files for Dreamweaver

    Creating your first web site in DW CC -  5-part tutorial.  Click on the blue GET FILES button to download the ZIP folder.
    https://helpx.adobe.com/dreamweaver/learn/tutorials/how-to/first-website-part1.html
    Nancy O.

  • Hi, i have Ipad 4 the mic is not working  skype account can  you tel me what i can do to get it working.

    Hi,
    i have ipad 4 the mic is not working for skype account can u tel me what i can do to get it working?

    No Japanese carrier provides unlocking services. Therefore, your phone must have been hacked to unlock it. That hack was removed when you updated the software. You need to be a legitimately unlocked phone.
    Best of luck.

  • Hello, Can you tell me where I can found the lens profil for the Canon 500MM F4 Mark II

    Can some one tell me where I could find this lens profile for Lightroom 5.4.
    thanks

    Given the 600mm F4 IS II (February 2011) lens profile hasn't been created yet it may be a while (if ever). I wouldn't worry about it since the lens profile only corrects distortion and vignetting. There is virtually no distortion with either of these lenses and vignetting is within 0.2EV using the 600mm profile, which you can set as the "default" profile. Personally I think people put too much emphasis on the need for "automatic" lens profile correction. All my lens profile defaults are set to Distortion = 0 and Vignetting = 50. I change the setting only when an image appears to need more correction. WHY?
    REASON
    Distortion correction crops part of the image and increases "edge" stretching with wide angle lenses–It's a trade-off for straight lines in the image. IMHO-If it's not visible in the image you don't need it. 100% Vignetting correction setting can look un-natural and amplifies lens aberrations and softness in the corners, which is where vignetting correction is applied the most.
    My 2 cents worth.

  • Can you tell me why I can not open any Missouri Federal or State forms

    When I log into a site to retrieve forms from the Federal or state of Missouri the form loads but will not open

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    You can remove all stored data from a specific domain via "Forget About This Site" in the right-click context menu of an history entry (Show All History or History sidebar) or via the about:permissions page.
    Using "Forget About This Site" will remove everything like bookmarks, cookies, passwords, cache, history, and exceptions from that domain, so be cautious and if you have a password or other data from that domain that you do not want to lose then make a note of those passwords and bookmarks.
    You can't recover from that "forget" unless you have a backup of the affected files.
    It doesn't have any lasting effect, so if you revisit such a 'forgotten' website then data from that website will be saved once again.

  • I purchased "Pages" on my ipad and have it on my iphone. Can you tell me if I can get on my Dell laptop.

    I purchased "Pages" on my ipad and downloaded it on my iphone and the data goes between both. I would like to have the ability to use "Pages" on my Dell laptop. Is is possible? Or do I need an Apple laptop? I appreciate any help you can provide, as I've been learning to use these things, through trial and error.
    Not the best way, I know.
    Thanks

    Indeed. You would actually have to buy an Apple computer (it doesn't have to be a laptop, depending on what you plan, a mac mini or an iMac would work of course). But, the version of Pages that you bought is for iOS only. You would have to buy the Mac OS X version of Pages for your Mac. But compared to the price of the Apple computer itself, this might not be the major issue ;-)

  • TS1646 hi can you tell me why i can not add my credit card

    will not let me add my credit card to my apple acc

    We are fellow users here on these forums, you're not talking to iTunes Support nor Apple.
    If you are getting a message about the card's security code, as on the TS1646 page that you posted from, then you've double-checked your card's details and you have exactly the same name address (including format and spacing) on your iTunes account as the card is registered to ? If you do then you've checked with your card issuer ?

  • Please can you tell me where I can get hold of Firefox 2.0.0.20. Thank you.

    This is for my elderly father who has a Mac OS 10.3.9. He only needs the computer to order groceries so does not really want to buy an upgrade for the Mac. The store he buys from have told him he will need Mozilla Firefox to access their site properly - at present he has Safari and for some reason he cannot get through the store checkout using Safari. (A problem with their website I guess). Thanks for your helpl.

    Firefox 2.0.0.20 is the last ever release for Mac OSX 10.3.9 and earlier versions. <br />Get it here: <br />
    https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.20/mac/en-US/

  • How can you tell who the original sender of a group text is on an iPhone 5, when all that appears is a list of recipients in no particular order

    how can you tell who the original sender of a group text is on an iPhone 5, when all that appears is a list of recipients in no particular order? I can't seem to identify the sender in the details list.

    Start a separate thread to the original sender.

  • I have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    Do you possibly mean the contacts have been merged?
    If so, where are each of you syncing contacts?  A supported application on the computer? iCloud or another cloud service? An Exchange server?
    WIthout details, it's difficult to offer specific resolutions.

  • How can you tell if a pic hasnt been tagged by iPhoto, and do you then...

    How can you tell if a pic hasnt been tagged by iPhoto, and do you then do you then have to draw "missing box" around them
    What I mean is tagged a few faces, imported some more pics, checked a few and they dont show as named faces, but are faces that are in my Faces source list (ie identified and named)
    So do I then have to draw a box around known faces to me, and name them again (I think iPhoto will pop up as Im typing the names I already have)
    It just means that even when i import and it doesnt name, I may have lots of pics that are of faces but not tagged and so not in my faces source list
    please help
    cheers
    ps when are Apple going to upload the Getting Started manuals for iLife 09? its been a while since released now, ad they give a bit more insight than the video tutorials alone

    No-one? It'll be nice to know how many pics of faces that arent yet tagged
    cheers

  • I have an Ipod 4th generation and an Iphone 5s, now i want to transfer my music files from Ipod to Iphone via Bluetooth, can you tell me  how to do this??

    i have an I pod 4th generation and an I phone 5s, now i want to transfer my music files from I pod to I phone via Bluetooth, can you tell me  how to do this??

    Withour know what the error message said try:
    iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues

  • How can you tell if a file is being used in your project or not?

    How can you tell if a file in your bin is being used in your project or not? My director dragged hundreds of reference files into my project and only used a few of them. I'd like to do some house cleaning and delete the ones that are not in use. This project file has 100 sequences in it, so it would be a tough manual hunt to figure this out.
    In Premiere Pro (or Flash for example), where all the information is in the Project Bin such as in/out times and duration, there is where it tells you how many times that piece of media has been used or if it hasn't been used yet.
    Can FCP tell me this info?
    Thanks for yout time!
    -Monty

    Monty,
    Within FCP, there is a menu item called "Media Manager" (depending on what version you are in). This would be worth your while to look into. It basically organizes your project by moving/archiving any used assets of a project and leaving out un-used assets. It saves a ton of disk space.
    For example, say you have a 5 minute clip with an in/out point that is just 30 seconds. Media Manager will "archive" just that 30 seconds, not the entire clip. There is even a setting that you can add additional "handles" time to the front andd back of the clip if you think you may need to add or change transition.
    Do a google search. I was just watching a few Youtube videos on this myself.
    Jonathan

Maybe you are looking for