How to know when all callbacks have arrived

I use code like
for(a thousand times){
org.xbill.dns.SimpleResolver.sendAsync()//query my nameserver
public void receiveMessage(Object id,Message msg){
resolutionsvector.add(msg)
public void handleException(Object id,Exception e){
how do i detect when all callbacks are received?
i tried counting but sometimes the queries match the resolutions while there are still new queries to be created (do not know why thread creation/use is slow sometimes) and sometimes the program fails to detect it has finished.
thought of creating a resolution class for the resolutionsvector saving the state of all queries and using an additional thead to test if all are processed once every second.
is that a way to do it or is there a design pattern for 'joining' the threads without being able to do exactly that (the threads are controled by a resolver class i would like to use without changing it) i should apply (if applies: where do i find documentation?)
best regards
erik

++

Similar Messages

  • How to know when mutiple threads have stopped?

    Hi all,
    I have a for loop in which multiple threads are started.Now I want to perform a UI action when all the threads have returned.But i am not able to make it out as when have all the threads returned.Can anyone help me out with it?
    Regards,
    Mansi
    Edited by: MansiSachar on Sep 1, 2008 11:33 PM

    Two methods I can quickly think of that will help you,
    I am sure that there is better ways of doing it just to lazy to check for and do them.
    method 1): Interface
    method 2): Runnable - run()--------------------
    publc interface MyThreadListener{
      public void threadGroupStarted();
      public void threadGroupFinnished();
    pubilc class GUI extends JFrame implements MyThreadListener{
      private MyOtherThread mot = null;
      public GUI(){
        init();
        mot = new MyOtherThread(this);
      public void threadGroupStarted(){
        System.out.println("Threads Started");
      public void threadGroupFinnished()
        System.out.println("Threads Finnished");
      public static void main(String[] args){
        new GUI();
    public class MyOtherThread{
      private MyThreadListener mtl = null;
      public MyOtherThread(MyThreadListener mtl){
        this.mtl = mtl;
      public void startNewParallelThread(.....){
    //Create a new thread in this class that will do the for(....) join().
    //Add the following code:
      mtl.threadStarted();
      for (Thread t : collectionOfThreads){
        t.join();
      mtl.threadFinnished();Creating a listener will enable you the have the second thread tell the first that it has finnished processing.
    pubilc class GUI extends JFrame implements Runnable{//better to create a Runnable Object that implement
      private Thread thread = null;
      public GUI(){
        init();
        thread =new Thread(this);
      public void run(){
        threadGroupStarted();
        for (Thread t : collectionOfThreads){
          t.join();
        threadGroupFinnished();
      public void threadGroupStarted(){
        System.out.println("Threads Started");
      public void threadGroupFinnished()
        System.out.println("Threads Finnished");
      public static void main(String[] args){
        new GUI();
    }

  • I've sent a group msg through messages but after a whole day it still says "outgoing". How do I know when all recipients have received the msg?

    I'm still not sure how many recipients received the group msg as it still says "outgoing".

    ++

  • How to know when ListView finished rendering elements?

    I have a ListView with many items inside.
    After I assign the ListView an ItemsSource, I need to know when all items finished rendering on my page.
    I can just nothing with my eyes it takes like 2 seconds to render all elements, and I need to subscribe to an event like "ListView.RenderingCompleted", because I can proceed with other operations after all elements are rendered and
    visible to the user ( meanwhile I can show a loading bar ).
    I cannot find something similar, how can I do that?

    >>I need to know when all items finished rendering on my page.
    I am afraid there is "all containers generated" event.
    The ListView uses UI virtualization so visual containers are only created for the currently visible items, i.e. not all the containers will be created at once.
    You could handle the Loaded event of the root item in the ItemTemplate to know when each individual container is ready for interaction:
    <ListView x:Name="listview" Height="200">
    <ListView.ItemTemplate>
    <DataTemplate>
    <Grid Loaded="grid_Loaded">
    <TextBlock Text="{Binding}"></TextBlock>
    </Grid>
    </DataTemplate>
    </ListView.ItemTemplate>
    </ListView>
    If you know the approximate number of items you can then for example write some code in the code-behind that hides the loading bar when a certain number of Loaded events has been raised.
    Or you could possibly handle the Loaded event of the ListView. The Loaded event occurs when the element has been constructed, added to the visual tree and is ready for interaction.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • How to know when invoke bytecode implements?

    I've got a classfile - it has few invokeinterface bytecodes inside - their count is defined dynamically - when class is running.
    And I've got a program, which runs this class.
    The aim of this program - to gather statistics of invokeinterface calling frequency.
    How to know when invokeinterface bytecode implements?
    (In that moment I plan to update several digits)
    Have You got an advise for me?
    Thanks.

    You must use the debugging interface, or get a code profiler. Do a search on all forums for profiler, you'll get tons of information.

  • HT2173 How to know when a hard drive has failed ?

    How to know when a hard drive has failed ?

    Machine doesn't boot.  You experience strange crashes.  Gets wrong results.  Your harddrive is five or more years old.  Time to consider repacing it.   You do have backup?
    You may want to run these "standard" fixes if the problem persists.
    1) Check the amount of free space on your harddrive.  You should have a several gigs free.
    2) You should run disk utility
         a) verify the disk
         b) update your permissions.
    3) Try a safe boot.
        Shutdown your machine.  Hold down the shift key.  Poweron.  Wait awhile Wait awhile while you harddrive
          is being checked.
        http://support.apple.com/kb/ht1455
    4) You may want to run applejack to clean up your machine.
         http://applejack.sourceforge.net/
    a lot more ways to fix your Mac.
    http://www.thexlab.com/faqs/faqs.html
    verify & repair your startup drive
    To verify & repair you file system on the startup drive, you will need to run disk utility from you installation DVD.
    This article  will tell you how to get to disk utility.  Once in a disk utility, you can go and attempt to recover the disk.
    http://support.apple.com/kb/TS1417
    To repair your startup drive, you will need to run disk utility from your startup DVD.
    Mac OS X 10.4: About the utilities available on the Mac OS X 10.4 Install DVD
    http://support.apple.com/kb/HT2055
    How to run disk utility from your startup DVD.
    Insert your  startup DVD  into your reader.  Power down your machine.  Hold down to the c key.  Power on your machine.  This will bootup your startup DVD.
    This will bring you to a panel asking you for your language.  Pick your language.
    You you come to the Install Mac OS panel.  Do not install.
    Click on Utilities menu item.  This will give you a pulldown list of utilities.
    Click on the disk utility.
    You are now in disk utility.  Pick your disk.  Click on repair it should be on the lower right of the panel.
    Once the repair completes successfully, you should update your permissions.
    Verify a disk
    As an alternative, you can verify that the filesystem on the disk is correct. You will not be able to repair the file system.
    I suggest that you use disk utility to verify that your startup disk is OK. 
    Macintosh-HD -> Applications -> Utilities -> Disk Utility 
    Start up disk utility.  On the left pane view, you will see a list of all your disks.  
    Click on your startup disk.
    Click on the First Aid  Tab.
    Click on verify.  
    Hopefully your disk will verify.  If not, you have to boot from your installation DVD and run Disk Utility from there to attempt to repair your file-system.

  • How to know when the JComboBox popup is about to show or hide?

    Hi all,
    In JDK 1.4, a new addPopupMenuListener() was added to the JComboBox component. I found out I have to use JDK 1.3, but I already wrote a lot of code around this particular capability. I am trying to figure out how to duplicate it in JDK 1.3. I need to know BEFORE and AFTER the popup is displayed. OR, is there a way with JDK 1.3 that as soon as they click the combo box, it fires an event. The thing is, as soon as they click it, I want to change the background color. When they are done selecting, I can use an ActionListener or ItemListener to find out what was selected and change the color again. My killer is trying to figure out how to know when they have selected the box. I tried adding MouseListener, PropertyChangeListener, AncestorListener. None are doing a thing when the JComboBox is first selected.
    Any help would be much appreciated.
    Thank you.

    Hi all,
    In JDK 1.4, a new addPopupMenuListener() was added to the JComboBox component. I found out I have to use JDK 1.3, but I already wrote a lot of code around this particular capability. I am trying to figure out how to duplicate it in JDK 1.3. I need to know BEFORE and AFTER the popup is displayed. OR, is there a way with JDK 1.3 that as soon as they click the combo box, it fires an event. The thing is, as soon as they click it, I want to change the background color. When they are done selecting, I can use an ActionListener or ItemListener to find out what was selected and change the color again. My killer is trying to figure out how to know when they have selected the box. I tried adding MouseListener, PropertyChangeListener, AncestorListener. None are doing a thing when the JComboBox is first selected.
    Any help would be much appreciated.
    Thank you.

  • I'm a Microsoft Outlook for Mac user, I need information of how to know when e-mail was readed and confirm receipt of e-mails sent. thank you!  regards Mauricio

    I'm a Microsoft Outlook for Mac user, I need information of how to know when e-mail was readed and confirm receipt of e-mails sent. thank you!  regards Mauricio

    Mail and Address book

  • How to know when the PRICE AFTER DISCOUNT changed and get the value

    Hi,
    Everything I do to see if a value changed in the grid works except for PRICE AFTER DISCOUNT
    which seems to be inaccessible.
    Any idea how to know when exactly this value changed and do actions accordinly ?
    Also I always get 0.00 if I try to get the value of it
    This works to get in the condition of a vlaue changing but I always get 0.00 as the value of the column
    if (pVal.ItemUID == "38" && pVal.ColUID == COL_DISCOUNT.ToString() && pVal.EventType == BoEventTypes.et_VALIDATE && pVal.ItemChanged == true && pVal.ActionSuccess == true)
        try
            SAPbouiCOM.Matrix Matrix = (SAPbouiCOM.Matrix)SBO_Application.Forms.ActiveForm.Items.Item("38").Specific;
            SAPbouiCOM.EditText Editor = (SAPbouiCOM.EditText)Matrix.Columns.Item(COL_DISCOUNT).Cells.Item(pVal.Row).Specific;
            SBO_Application.MessageBox("Discount changed for : " + Editor.Value + "...", 1, "Ok", "", "");
        catch (Exception ex)
            SBO_Application.MessageBox(ex.Message, 1, "Ok", "", "");
    And this do not even get into the condition even tought I SEE the column PRICE AFTER DISCOUNT:
    if (pVal.ItemUID == "38" && pVal.ColUID == COL_PRICEAFTERDISCOUNT.ToString() && pVal.EventType == BoEventTypes.et_VALIDATE && pVal.ItemChanged == true && pVal.ActionSuccess == true)
        try
            SAPbouiCOM.Matrix Matrix = (SAPbouiCOM.Matrix)SBO_Application.Forms.ActiveForm.Items.Item("38").Specific;
            SAPbouiCOM.EditText Editor = (SAPbouiCOM.EditText)Matrix.Columns.Item(COL_PRICEAFTERDISCOUNT).Cells.Item(pVal.Row).Specific;
            SBO_Application.MessageBox("Price after discount changed for : " + Editor.Value + "...", 1, "Ok", "", "");
         catch (Exception ex)
             SBO_Application.MessageBox(ex.Message, 1, "Ok", "", "");

    just idea, maybe it will works
    Create one udf in row level and set there FS based on changes on price after discount and fill value what is in price after discount. Then the validation make on this field instead of standard SAP field.

  • How i know when a EXECUTE_QUERY retrieved last record

    Hi...
    How i know when the EXECUTE QUERY retrieved the last record in a block ....?
    Exist a trigger after trigger POST-QUERY?
    Regards
    Hector Gabriel Ulloa Ligarius
    Santiago of Chile
    http://es.groups.yahoo.com/group/desarrolloOracle/

    Kevin, sorry
    But the :system.last_record not change the value during the execution of EXECUTE_QUERY.
    Only useful when the data was retrieved into blocks...not during..
    Other mode?
    Regards
    Hector Gabriel Ulloa Ligarius
    Santiago of Chile
    http://es.groups.yahoo.com/group/desarrolloOracle/

  • How to know when I'm doing a createInsert?

    how to know when I'm doing a createInsert, this to hide a button when you run this action, I am using a task flow.
    my version of jdeveloper is 12c

    hi,
      So you are using the createInsert as a method call in task flow. That is your form/table will be come new rows and you want to disable some button.
    Your task flow might be as below
          CreateInsert---->Page.
    To do so
    1.) Take properties of your method call and bind the Method property to a method in a bean (bean registered in the task flow with scope view or any higher scope)
    2) Call the create insert operation programmatically in that method.
    3) And in that method after the createinsert ,set a boolean variable in pageFlowScope.
    4)Put this variable in the disable property or visible propery of the button you wabt to hide/diable.
    eg:
        public void doCreateInserOperation(){
            try {
               // Programatically invoke CreateInsert
                DCBindingContainer bindings = (DCBindingContainer)getBindingContainer();
                bindings.getOperationBinding("CreateInsert").execute();
            //Set a variable in page Flow Scope 
            AdfFacesContext.getCurrentInstance().getPageFlowScope().put("disableButton", true)
            } catch (Exception e) {
                e.printStackTrace();
        public BindingContainer getBindingContainer() {
            FacesContext facesContext = getFacesContext();
            Application app = facesContext.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = facesContext.getELContext();
            ValueExpression valueExp = elFactory.createValueExpression(elContext, "#{bindings}", Object.class);
            return (BindingContainer)valueExp.getValue(elContext);
    you can access this variable in EL expression as #{pageFlowScope.disableButton}. So when your page render it will be in CreateInsert mode and the button will be disabled/hidden.
    I hope this will help you.
    With regards,
    Gijith.

  • How to download when i already have a serial number, but no drive to install the cd in my lap

    how to download when i already have a serial number, but no drive to install the cd in my lap

    Download the trial version and activate it.
    Mylenium

  • How to know where all my Update of a field created records (Like when we have nested triggers)

    How do I know where all( in which tables) the new records are created when I've updated a field in a Table.
    I've updated a field it displayed. actually it updated only one row in my original table
    1 row effected.
    1 row effected
    1 row effected.
    1 row effected.
    four times.
    So I realized and seen the triggers defined for that table, then also I was able to find only one record inserted in a different table through record.
    How to know all the tables where all my update  ...cause to insert records.

    do you've a common field between tables or an audit column like datemodified?  If yes, you can use them to find out recently inserted records from the affected tables.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to know when I have scrolled to the bottom of my advancedDataGrid

    I need to know when I have scrolled to the bottom of my advancedDataGrid or when the last row appears on the screen. Is there anyway of getting this?
    I tried to do it by the verticalScrollPosition, but I don't know how to find the maxScrollPosition.
    Any help would be appreciated.

    Follow above instructions. Use the App Store to get applications for your computer via Apple. Apps for your iDevice are purchased through the iTunes Store. These are two different stores. Now you will have Numbers on your iPhone or iPad or iPod Touch, and then one for your Mac computer.
    The Dock icon for the App Store looks like this:

  • HT204266 I used several apple and iTunes gift cards on my account with relevant codes.  How can I verify all cards have been used when total purchases don't line up?

    I have used several apple app and itunes gift cards to purchase apps and music with no problem.  Codes were entered as required.  Is it possible to get a printout of the card amount and codes to check against purchases.  My total is not jiving.

    No, you can't see a list of card redemptions, nor how items were billed - all you can do is view your account's purchase history via your computer's iTunes : log into your account on your computer's iTunes via the Store > View Account menu option, you should then see a Purchase History section with a 'see all' link to the right of it. Click on that and you should then see a list of your purchases.

Maybe you are looking for

  • Can connect two Macs with USB2 cable?

    Can connect two Macs with USB2 cable?

  • How can I get the run time of a method?

    I click a button "draw" to invoke a method such as draw many shades. It hangs a long time. I want to get the information of how long it spent. How can I do it? I'm new guy, more detailed please . one example would be much better ThankS all :)

  • Hint:  Start a Java Console Window to diagnose problems in Workflow Designer

    Hello - A trick you can use to try and identify problem you are having using the Workflow deisgner is to turn on the JavaConsole for the designer session. On windows you can do this by modifying the shortcut to start designer. Add the following param

  • Turn in app on

    How do I turn "in app" button on? Tried passcode and new passcode

  • Management Consolidation

    Hi Friends Have you ever done consolidation per profit center? Actually my client wants a managemet consolidation, is posible to do this at the same consolidation area? because according to help.sap the consolidation area is for that. what is the fir