Any way to notify when a Thread terminate ?

There's any way to notify (to other classes) when a thread terminate? Can I use an ActionEvent to notify that the thread is terminated ?
Thank you
Giorgio

Hi,
It depends what you're trying to do. A common occurrence is one thread waiting for another thread to complete. You can achieve this using the join() method on java.lang.Thread:
Thread t = new Thread(new Runnable() {
public void run()
// do some long winded task A
t.start();
// do task B that will run concurrently with A
// block this thread until task A completes
t.join();
(exception handling omitted for brevity)
For general notification between threads, the wait() and notify() constructs are commonly used. These are called on an object and can only be called in code blocks synchronized on that object. There are a whole gammut of issues to be aware of when using threads in this way; I'd strongly recommend getting a good book on the subject (e.g. "Concurrent Programming in Java, Second Edition" by Doug Lea.
null

Similar Messages

  • Any way to detect when a NotificationListeners MBean is removed?

    If I have an MBeanServerConnection through which I register a NotificationListener, is there any way to detect when either the MBean that the NL is registered for is removed or destroyed?
    Specifically, I fire up a process, register an MBean.
    A client connects to the process, and registers a NotificationListener.
    Finally, I destroy the original process. How can I be notified that this has happened in my NotificationListener Client?
    Is there something else I can use to monitor the JMX connection?

    It sounds as if you are looking for a notification when an MBean is unregistered. To get that, you need to register a listener on the MBean Server Delegate. See MBeanServerDelegate and MBeanServerNotification.
    Regards,
    Éamonn McManus -- JMX Spec Lead -- [http://weblogs.java.net/blog/emcmanus]

  • Is there any way to know when (and/or whether) a particular tv season will be available for purchase on itunes.  i'm particularly interested in the 2nd season of "homeland," the 5th season of "damages" and the 7th season of "dexter."  thanks.

    is there any way to know when (and/or whether) a particular tv season will be available for purchase on itunes.  i'm particularly interested in:
         the 2nd season of "homeland,"
         the 5th season of "damages"
         the 7th season of "dexter."
    thanks.

    Thanks. But the disc inspector only appears to let me change things like where the title menu button takes you, not detailed user operations. I have pretty much given up on this being anything other than a giant hassle, but if anybody knows whether a script could do this, I would be eternally grateful.

  • HT201209 any way to see when I redeemed an itunes card

    Is there any way to see when I redeemed an itunes card? I have had £2.99 go "missing" but I have been told that iTunes doesnt always update my balance??????
    I checked my balance, it said £3.82, I went back to my game, tried to make a £2.99 purchase only to be told I didnt have enough funds in my iTunes account (just so happened that my itunes account was suddenly £2.99 down!)

    You just make a purchase and it will deduct it.

  • Is there any way to interrupt the sleeping thread ?

    Is there any way to interrupt the sleeping thread ?
    regards,
    namanc

    Thread.interrupt, very
    sneakily hidden by being in the javadocs under the
    class you know you're using, as a method named by what
    you want to do.:o)
    Here's more:
    Java's Thread Tutorial
    JavaWorld: Introduction to Java threads
    IBM: Introduction to Java threads
    Google: java+threads+tutorial

  • Is there any way to know when an app is going to be discontinued?

    I purchased an app around eight months ago for $13. I forgot about it until I was reloading apps onto my new IPad. When I went to find it, it was no longer in the app store at all. I contacted the support people who told me that since it was "so long ago" there was no recourse.  So does that mean that any time you purchase an app it could disappear at any moment? Is there any way to know in advance that this will happen?  Never mind that it stinks to spend that amount of money and then have nothing to look back at.
    Additionally, I have had trouble reloading apps that I have paid for as an "in app purchase".  What is the deal with that?  Is that information not stored like buying an app outright?
    Thanks
    DTC

    Apple constantly reminds folks to backup their content. Apple warns folks all of the times that content may not always be available in the iTunes or Mac App Stores and most folks ignore the warnings or cannot be bothered to read them. No, unless the developer warns you that they are with drawing an app from one of the stores, there is no way to know in advance that an app may no longer be available.
    http://support.apple.com/kb/ht4009

  • Is there any way to prempt the finalization thread?

    I am a lead programmer for customizations to an application my company purchased. After many OutOfMemory errors I tracked down that some code had finalize() methods that could be factored out, allowing more memory to be truely garbage collected quicker. This helped enormously, but we use a third party tool for which I cannot get rid of the finalize() methods.
    What I've observed repeatably is that the Sun JVM, version 1.4.2_15, will not run the finalizer even with Runtime.getRuntime().runFinalization() if the system is under load. Yes, I know the docs say it is a just suggestion, but thats not the real `world need. Rather than running finalization and freeing memory, the JVM would rather run completely out of space, which is retarded. Given all this, here's what I need to know:
    Is there any command-line switch or other option or method by which I can force the JVM to stop and run the finalization thread on some interval, or to heed my direct programatic requests (even at the expense of the rest of the application)? Surely with all the GC-related options there's something to help those of us with poorly written third-party codebases?

    I could always be wrong (it has happened before) but I've thrown about everything at this problem and I'm confident that the problem is that the finalizer is not running. Here's why:
    I've noted over several tries that if I create a thread that calls runFinalization, it will block until finalization completes. I've also noted that if my test load is removed (or finishes), after some undefined period this special-purpose thread I created will return. This is the only indication I can find (in any debug output anywhere) that finalization has occurred. When it does return ... the memory usage just plummets, indicating a large reserve of objects in the finalization queue.
    The coming-back-to-life scenario seems unlikely. I can at least see, if not modify, what our third-party tool is finalizing, and there doesn't appear to be any bring-me-back-to-life code. Mainly just doing connection-releasing semantics that they should have done another way (as I have with the other block of code with much success).
    I'm not sure this could qualify as a bug. Bug implies that there's something wrong. What I need has appeared (at first glance) to be a **missing** (albeit much needed) feature.
    Unfortunately, 1.4.2_15 is as high as we can go and still retain some level of support for the whole purchased app. Believe me I'd love to go higher, but that's the max for now. Just this last fall we upgraded from 1.3.1 ... so we're just now reaping these rewards. (BTW, I don't know if 1.3.1 had these problems, we were more concerned with other things at the time).

  • Any way to fix when Firefox locks up or prevent it from happening?

    I used Firefox on the mac, and while I much prefer it to Chrome, I've had no end of stability problems over the last several months, across multiple computers and installs.
    The problem is that sometimes it will just... freeze up. Spinning ball for the app, completely unresponsive, nothing I can do, sitting at 100% cpu usage. I've let it sit like this for a while, and once or twice it's come up with a "unresponsive script" error, but viewing the same pages in Chrome or Safari never seems to cause an issue and I need to view these pages.
    My solution so far has been to force quit Firefox when this happens, but losing what I've been working on has been rough now that it's happening 2 or 3 times a day. What I'm wondering is if there's a better way to handle this than destroying it - can I change some setting that says "if it doesn't work for 3 seconds, kill the problem script or whatever don't wait an hour" or to force it to stop whatever it is doing and respond to my commands?

    [[Warning Unresponsive script - What it means and how to fix it]] this will give the option.
    Consider addons.mozilla.org to search for a feature that might also address controlling scripts.

  • Is there any way to tell when a task has a lock

    Normally I can just keep track of it. But upon an external termination I can get into problems. If I don't release a lock, well it stays locked. If I release it and don't have it I get a run time error. But I can't find a way to ask a lock if I have it.

    ChasGI,
    Unfortunately, there is not a way to query a lock to determine what/who posseses it.
    The Get Status lock operation returns the Number of Threads Waiting to Lock the Lock. You could get creative with that.
    Matt P.
    Applications Engineer
    National Instruments

  • Is there any way to know when block corruption occurred?

    In Oracle when block corruption happens; it does not write to alert.log. If one is running dbv or rman backup is being done or rman validate command is run then one knows about corruption. However, one does not know when actually corruption occurred. Is there a way to know exact time of corruption?

    I am using cooked file system, no async i/o, no asm. However, by default on HP UNIX disk_asyncio=true ib iit.ora but I had read if there is no aysnc dveice set; i/o will be sychronous i/o. I am using Oracle 11g database on HP UNIX 11.23.
    There are several other database instances on that server using oracle 11g and Oracle 10g and they do not have problem. Only one instance in QA and one in PROD has block corruption. Luns on XP are created by Storage
    group and Logical Vloumes on UNIX are set ny UNIX admins. Each instange is on separte volume group and separate ORACLE_HOME.
    I suspect somehow something was not set correctly in LUNS or in logical volmes. However, HP enginerrs cannot find naything wrong; so root cause is still unknon.

  • Any way to know when iPhone is completely charged?

    Good afternoon.
    Just got my iPhone and it activated and ready to go!!!
    Been putting music, photos, etc. on to it, but was wondering...
    How do you know when it is completely charged? How long should you charge it initially?
    Thanks.

    Yes I do have the icon.
    I just didn't know if it said charged on the screen
    like the iPod or something like that...
    Thanks again.
    Yes, I see that the icon is green when charged, but then it is suddenly white as the phone is used. Are there supposed to be any in between indicators?

  • Any way to see when an iphone 5s has been updated by date and time?

    anyway to see when an iphone 5s was updated by date and time? that info is very important

    Warren,
    The message doesn't show if you use a local (it does when you use a property
    node!). The boolean does blink!
    Try the attached VI.
    Regards,
    Wiebe.
    "Warren Massey" wrote in message
    news:5065000000050000007C570100-1075935269000@exch​ange.ni.com...
    > I've already tried something like this and it just does not work like
    > I want it to.
    >
    > Enforced with a sequence structure I do this:
    > 1) put up a message saying "Updating"
    > 2) dump the updated data to the display
    > 3) clear the message
    >
    > What I see on the CRT is this:
    > 1) a message saying "Updating"
    > 2) the message quickly goes away
    > 3) several seconds later the image changes.
    >
    > My kludge/workaround is to add a variable delay before the message
    is
    > cleared. The delay is based on the image size and some
    > empirically-derived constants.
    [Attachment Picture Update.vi, see below]
    Attachments:
    Picture_Update.vi ‏45 KB

  • Is there any way to tell when a device was last synced?

    I have misplaced my iPad and to cut a long story short, by knowing the last time it synced over wifi will give me a starting point as to where  it could be.

    You can look in Finder under
    ~/Library/Application Support/MobileSync/Backup
    ~ is your Home folder.

  • Notify when server shutdown

    Hi,
    Is there any way to notify the my servlet class, when the server is shutdown?
    So that I can call saveDataToDB method to seave the unsaved data and cleanUp method to close the other system connection properly.
    Thanks & Regards
    Abhay

    did you consider implementing the destroy() method of the Servlet interface?
    see the javadoc:
    destroy
    public void destroy()Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. See Servlet.destroy().

  • IS THERE ANY WAY TO FORCE KEY COMMIT

    Hi:
    Is there any way in forcing when inserting/updating a record in a block to call KEYCOMMIT. For Example, if the user inserted/updated a record and before saving the user may quit the form. I would like to enforce the keycommit trigger to be called when the form is opted to close.

    Hello,
    Try the following in Key-Exit trigger:
    BEGIN
    IF :system.form_status = 'CHANGED' THEN
    DO_KEY('COMMIT_FORM');
    ELSE
    EXIT_FORM(NO_VALIDATE);
    END IF;
    END;
    Regards,
    George
    Hi:
    Is there any way in forcing when inserting/updating a record in a block to call KEYCOMMIT. For Example, if the user inserted/updated a record and before saving the user may quit the form. I would like to enforce the keycommit trigger to be called when the form is opted to close.

Maybe you are looking for