Wait for all threads in a array to die

I everyone. I'm from Portugal and I have some experience in JAVA programming (approximately five years) but this is the first the first time that i'm trying to use threads. I'm trying to learn writing some simpler code that does almost exactly at the basic level the same stuff that a complex application that I need to write for my work.
What I'm trying to do is execute a counter that counts all operations in threads belonging to the same array (an array of n threads).
A static variable in the Thread class (implementing Runnable) counts all operations performed by all threads and sums them all and shoud display the total of operations after all threads terminate, but this exactly what I don't know how to do:
This is my example code:
public class TT1 implements Runnable {
     int id;
     double last_number;
     static int threads_counter = 0;
     static int total_threads = 4;
     static long total_numbers;
     int total_randoms = 1000;
     public void run() {
          for (int i=0;i<total_randoms;i++)
               total_numbers++;
               // does some stuff, in this case, generate a random number!
               last_number = Math.random();
          System.out.printf("Thread %d:%f(%d)\n",id,last_number,total_numbers);
     public TT1() {
          id = threads_counter++;
          new Thread(this).start();
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          Thread [] threads = new Thread[total_threads];
          for (int i=0;i<threads.length;i++)
               threads[i] = new Thread(new TT1());
          /* commented code using join(), is not working or I don't know
          how to use it! */
          for (int i=0;i<threads.length;i++)
               try {
                    threads.join();
               } catch (InterruptedException e) {
                    e.printStackTrace();
          try {
               threads[total_threads-1].join();
          } catch (InterruptedException e) {
               e.printStackTrace();
          // this line should be executed ONLY after ALL threads have died!
          System.out.println("******GENERATED NUMBERS TOTAL:" + total_numbers);
Somebody can give me a hint how to solve this ?

Thanks for your replies.
Actually, i've corrected the code, now i'm starting the threads outside the constructor. Originally I thought this could be a simpler way to create the threads: launching them at same time I'm creating them! Is this wrong ? :) Well, watching the results.
I changed my code:
public class TT1 implements Runnable {
     int id;
     double last_number;
     static int threads_counter = 0;
     static int total_threads = 4;
     static long total_numbers;
     int total_randoms = 1000;
     public void run() {
          for (int i=0;i<total_randoms;i++)
               total_numbers++;
               // does some stuff, in this case, generate a random number!
               last_number = Math.random();
          System.out.printf("Thread %d:%f(%d)\n",id,last_number,total_numbers);
     public TT1() {
          id = threads_counter++;
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          Thread [] threads = new Thread[total_threads];
          /* create individual threads */
          for (int i=0;i<threads.length;i++)
               threads[i] = new Thread(new TT1());
          /* launch the threads (NEW CODE) */
          for (int i=0;i<threads.length;i++)
               threads.start();
          /* commented code using join(), is not working or I don't know
          how to use it! */
          for (int i=0;i<threads.length;i++)
               try {
                    threads[i].join();
               } catch (InterruptedException e) {
                    e.printStackTrace();
          // this line should be executed ONLY after ALL threads have died!
          System.out.println("******GENERATED NUMBERS TOTAL:" + total_numbers);
And I obtain the output:
$ java TT1
Thread 0:0,191546(1000)
Thread 1:0,937476(2000)
Thread 2:0,825079(3000)
Thread 3:0,451367(4000)
******GENERATED NUMBERS TOTAL:4000Exactly as I want it!
All is good when it works good ;)
Best regards

Similar Messages

  • Waiting for a thread to die.

    Hello, I hope you can help me...
    I am writting a jdk1.4.1 Swing application that displays a small animation. This animation is processed from within a separate thread. My program makes a call starting this 'animation thread'. For practical reasons my program needs to wait for this thread to die (and thus the full animation to be shown) before it can continue. I am waiting for the animation thread to die using Threads 'join' method. However the problem with this is that I am forcing the GUI thread to wait resulting in the animation being calculated but not displayed. And so... how can I fix this... all I want is to wait until the animation is shown.
    What I would like to do is:
    1. Start animation;
    2. wait intil animation has completed;
    3. continue with program.
    Any help or advice will be greatly appreciated.
    Thank you in advance.

    Maybe this design could work for you. You divide your program into three parts running in three separate threads.
    1. The main thread handling GUI stuff and coordination of the two other threads.
    2. A working thread doing most of what the main thread is now doing.
    3. The animation thread.
    With this division of labour the working thread is waiting for the animation thread to finish (the main GUI thread isn't). The main thread will be free at all times to react to the users input or updating the screen or whatever, while the other two threads are cooperating to produce the animation.

  • Application waits for the thread to finish

    Hi all,
    I have a class let say test that extends Thread.
    In my application i say:
    test Xtest = new test();
    Xtest.start();
    System.out.println("Thread finished");
    I need my application to wait for the thread to finish for it to continue, i.e. in my example print "Thread finished" .
    Can someone help me.
    Thanks in advance for your help.
    Best regards,
    Saadi MONLA

    This should work:
    test Xtest = new test();
    Xtest.start();
    Xtest.join();
    System.out.println("Thread finished");

  • Waiting for many threads

    Hey guys,
    I know how to make one thread wait for another named thread to complete, but how do u make a thread wait for many threads to complete with the added problem of not knowing the names of the threads your waiting for? Looked and been trying for ages but can't get anything to work.
    Thanx
    Lisa

    No i saw it, pehaps i should rephrase with a question, how would you go about giving all these threads a reference? If it ain't obvious already am not great with java and if someone could tell me how to give the threads spawned references it would be great.
    As ive explained the code is really long so am not going to waist peoples time by posting it. Here is basically how i am spawning the threads "willy-nilly" style.
         while ((p < searchTerms.size())&&(p < 30)){
             term = (searchTerms.elementAt(p)).toString();
             NetChecker nc = new NetChecker(term,excludedAdds,refWeb);
             searchClasses.addElement(nc);     
             new Thread(nc).start();
             p++;
         } the classes all return web addresses in a vector, thats why i need all the threads to complete so i can collect all the results
    Thanx
    Lisa

  • Can't export as Html (Waiting for all files to be ready...)

    Made a bunch of updates last night to a client site.  Everything looks great except I can't export as Html. Had my sister try to export on her computer and we both get to 87%, then it permanently stalls, saying "Waiting for all files to be ready" (See screenshots). We've ensured that no files are open or being previewed. We've rebooted and tried saving to a different location, all with no change, we still get to the 87% mark and stop. Please help. I have a client waiting for this site update.
    Details:
    Windows 7
    Sony Vaio
    Muse Version - 4.1 Build 8 *see screenshot
    ****Update:
    I can preview the entire site in a browser as well as preview each page individually, but cannot finish a html export past 87%.

    Odd are if you wait long enough, potentially a few hours, it will complete.
    This huge performance hit sounds exactly like a bug that's fixed for the Muse CC 5.0 release due out next week. Sorry for the inconvenience.

  • Broker wait for all receiver to acknowledge before returning from publish()

    Does the broker wait for all receiver to acknowledge before returning from publish()?
    If suppose i had 10 subscribers. I observerd 10th subscriber getting message late. I thought publisher will wait for acknolodge for each subscriber ? else why it getting message late ?

    I assume you are questioning why the subscriber's onMessage() is getting
    called way after the publisher's publish() had returned.
    The JMS publishers only know that it is sending msgs to a destination.
    Whether there are 0 or 100 subscribers to the destination is something it
    doesn't know or care about.
    The message is sent to a destination on the broker first and then it is
    delivered to the subscribers of the destination.
    The publisher's publish() method will not return until the message has
    been successfully delivered (and persisted if necessary) to the broker.
    Note that this does not mean that the message has been successfully
    received by any subscribers.

  • Waiting for multiple threads to complete.......

    Search the forum archives but have not found a definitive solution...
    I have java app which spawns many threads (runnable objects) in the main() method. As one would expect, main exits before the threads finish but I don't want this to happen. I want to wait until all the threads have completed so I can use the results (stored in a vector) in the main thread....kindof like waitformultipleobjects in windows NT...
    does any guru out there know how best to achieve this????
    thanks

    Have you tried using a ThreadGroup? I imagine something like the following. I think it is not so nice because of the empty while loop but you get the idea.
    public class ThreadGroupTest {
         private static class Dummy extends Thread{
              private long sleepms;
              private String msg = null;
              public Dummy(ThreadGroup tg,long sleepms){
                   super(tg,"test"+String.valueOf(sleepms));
                   this.sleepms = sleepms;     
              public void run(){
                   try {
                        Thread.sleep(sleepms);
                   } catch (InterruptedException e) {
                   this.msg="Slept "+String.valueOf(sleepms)+" millis.";
              public String getMsg() {
                   return msg;
         public static void main(String[] args) {
              Dummy[] threads = new Dummy[10];
              ThreadGroup tg = new ThreadGroup("test");
              for(int i = 0;i<10;i++){
                   threads[i] = new Dummy(tg,(i+1)*1000);
                   threads.start();
              while(tg.activeCount()>0){
                   System.out.println(tg.activeCount());
              for(int i=0;i<threads.length;i++){
                   System.out.println(threads[i].getMsg());
    Hope that helps.

  • Standby media recovery waiting for inactive thread

    Hi,
    Please let me know any idea on this scenario. Thanks.
    Environment:
    Oracle 11.2.0.2
    primary: 3 node RAC
    standby: 3 node RAC
    Problem:
    there is thread 5 (not registered instance or did not show in srvctl) that generates archivelog. but the lag apply stopped because of this when the instance (of thread 5) is shutdown.
    question: somehow an instance is registered in the cluster but in srvctl only 3 instance is running. it should have 4 instance but 1 is not running. How can I remove the thread 5 so when someone startup then shutdown instance#4 it will not create archivelog that will stopped the apply of archivelog in standby.
    note: this is perf environment server so someone and "other" DBA is accessing this environment which I am not aware what are they doing with the cluster.
    looking in alert log file: - it is waiting for thread 5 sequence 510. But the instance is down so log is not shipped to standby database and this resulted to lag in other threads.
    Sat Aug 03 18:54:47 2013
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_1_seq_13718.1544.822333555
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_2_seq_17665.22678.822315375
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_3_seq_15465.14138.822313997
    Media Recovery Waiting for thread 5 sequence 510
       THREAD# LAST_SEQ_RECEIVED LAST_SEQ_APPLIED
             1             13745            13717
             2             17728            17664
             3             15527            15464
             5               509              509
    what I did is:
    1. primary (asm copy to file system)
    2. scp primary to standby
    3. standby (file system copy to asm)
    4. rman target / -> catalog archivelog <thread 5 sequence 510)
    5. then looking into alert log file; it performed media recovery
    Sat Aug 03 23:03:13 2013
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_1_seq_13718.1544.822333555
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_2_seq_17665.22678.822315375
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_3_seq_15465.14138.822313997
    Media Recovery Waiting for thread 5 sequence 510
    Sat Aug 03 23:15:21 2013
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_5_seq_510
    Sat Aug 03 23:15:32 2013
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_3_seq_15466.10925.822316315
    Sat Aug 03 23:17:18 2013
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_2_seq_17666.853.822333143
    Sat Aug 03 23:18:39 2013
    Media Recovery Log +FLASH/dgjmspl/archivelog/2013_08_01/thread_3_seq_15467.834.822333553
    Sat Aug 03 23:20:54 2013

    in Standby, thread 4 and 5 are both UNUSED, and size is incorrect (not equal to other redo log). I want to recreate it but cannot drop redo log. I follow Doc ID 740675.1.
    any idea what are the missing steps? thanks.
    ORA-01624: needed for crash recovery of instance UNNAMED_INSTANCE_5 (thread 5)
    select group#,thread#,archived,status,bytes from v$log;
    primary DB:
        GROUP#    THREAD# ARC STATUS                BYTES
             1          1 YES INACTIVE         1073741824
             2          1 YES INACTIVE         1073741824
             3          2 NO  CURRENT          1073741824
             4          2 YES INACTIVE         1073741824
             5          3 YES INACTIVE         1073741824
             6          3 YES INACTIVE         1073741824
             7          2 YES INACTIVE         1073741824
             8          1 NO  CURRENT          1073741824
             9          3 NO  CURRENT          1073741824
            10          4 YES INACTIVE         1073741824
            11          4 NO  CURRENT          1073741824
        GROUP#    THREAD# ARC STATUS                BYTES
            12          4 YES INACTIVE         1073741824
            13          5 YES INACTIVE         1073741824
            14          5 YES INACTIVE         1073741824
            15          5 NO  CURRENT          1073741824
    standby DB:
        GROUP#    THREAD# ARC STATUS                BYTES
             1          1 YES INACTIVE         1073741824
             2          1 YES INACTIVE         1073741824
             3          2 NO  CURRENT          1073741824
             4          2 YES INACTIVE         1073741824
             5          3 YES INACTIVE         1073741824
             6          3 YES INACTIVE         1073741824
             7          2 YES INACTIVE         1073741824
             8          1 NO  CURRENT          1073741824
             9          3 NO  CURRENT          1073741824
            10          4 YES INACTIVE         1073741824
            11          4 NO  CURRENT          1073741824
        GROUP#    THREAD# ARC STATUS                BYTES
            12          4 YES INACTIVE         1073741824
            13          5 YES INACTIVE         1073741824
            14          5 YES INACTIVE         1073741824
            15          5 NO  CURRENT          1073741824

  • Waiting for a thread to finish

    I've been researching this issue for a couple of days, but I dont think I know enough about threading to ask the right question in a search engine. Sorry if this is a basic blunder....I dont write swing often and it shows.
    I have a swing app that includes a long task so I have implemented a progress bar. I need to wait until the progress bar task completes before continuing to the rest of the method. I've tried:
    1. Putting the progress bar within a while loop (while task not complete...) but the progress bar dialog does not render fully. I've even added repaint, but still the dialog looks blank.
    2. SwingUtilities.invokeLater, but it doesnt wait until the progress bar is finished
    3. SwingUtilities.invokeAndWait, though after all the reading I did about deadlock conditions I didnt like the idea. However I was desperate so I tried it and got an error:"Cannot call invokeAndWait from the event dispatcher thread".
    4. Putting the code that needs to occur after the progress bar in an "invokeLater" thread
    5. I've also used the ProgressBarDemo from the java.sun example with the swingworker hoping the worker thread would handle the issue.
    A much smaller version of the code is below:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.Border;
    public class ProblemCode extends JFrame
         private JFrame jFrame = null;
         private JPanel jMain = null;
         private JButton startButton = null;
         public ProblemCode()
              initialize();
         public void initialize()
              //Setup the main application window size
              jFrame = new JFrame();
              jFrame.setContentPane(getJMainPanel());
              jFrame.pack();
              jFrame.addWindowListener(new java.awt.event.WindowAdapter()
                   public void windowClosing(java.awt.event.WindowEvent e)
                        dispose();
              SwingUtilities.invokeLater(new Runnable()
                public void run()
                    jFrame.setVisible(true);
         private JPanel getJMainPanel()
              if(jMain == null)
                   jMain = new JPanel();
                   jMain.add(getJStartButton());
              return jMain;
         private JButton getJStartButton()
              if (startButton == null)
                   startButton = new JButton();
                   startButton.setText("Start");
                   startButton.setVisible(true);
                   startButton.addActionListener(new ActionListener()
                       public void actionPerformed(ActionEvent e)
                           SwingUtilities.invokeLater(new Runnable()
                                 public void run()
                                          progBar();
                            System.out.println("Do this after the progress bar completes");
                            SwingUtilities.invokeLater(new Runnable()
                                 public void run()
                                      System.out.println("invokeLater doesnt work either....");
              return startButton;
         private void progBar()
            JFrame jProgFrame = new JFrame("JProgressBar Sample");
            jProgFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container content = jProgFrame.getContentPane();
            final JProgressBar progressBar = new JProgressBar();
            new Thread()
                private int counter = 0;
                private final int val = (int)(Math.random()*10)+1;
                public void run()
                    for(int i = 0;i <= 100;i++)
                        counter += val;
                        javax.swing.SwingUtilities.invokeLater( new Runnable()
                            public void run()
                                progressBar.setValue(counter);
                        try
                            Thread.sleep(500);
                        catch (InterruptedException e)
            }.start();
            progressBar.setStringPainted(true);
            Border border = BorderFactory.createTitledBorder("Reading...");
            progressBar.setBorder(border);
            content.add(progressBar, BorderLayout.NORTH);
            jProgFrame.setSize(300, 100);
            jProgFrame.setVisible(true);
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        new ProblemCode();
    }Thank you for taking the time to review this.

    Hi,
    I made some tiny changes in yoyr code, marked with
    // PBHere the changed code
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.Border;
    public class ProblemCode extends JFrame {
        private JFrame jFrame = null;
        private JPanel jMain = null;
        private JButton startButton = null;
        public ProblemCode() {
         initialize();
        public void initialize() {
         // Setup the main application window size
         jFrame = new JFrame();
         jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // PB
         jFrame.setContentPane(getJMainPanel());
         jFrame.pack();
         jFrame.addWindowListener(new java.awt.event.WindowAdapter() {
             public void windowClosing(java.awt.event.WindowEvent e) {
              dispose();
         SwingUtilities.invokeLater(new Runnable() {
             public void run() {
              jFrame.setVisible(true);
        private JPanel getJMainPanel() {
         if (jMain == null) {
             jMain = new JPanel();
             jMain.add(getJStartButton());
         return jMain;
        private JButton getJStartButton() {
         if (startButton == null) {
             startButton = new JButton();
             startButton.setText("Start");
             startButton.setVisible(true);
             startButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                       progBar();
                  System.out
                       .println("Do this after the progress bar completes");
                  SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                       System.out
                            .println("invokeLater doesnt work either....");
         return startButton;
        private void progBar() {
         JFrame jProgFrame = new JFrame("JProgressBar Sample");
         jProgFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container content = jProgFrame.getContentPane();
         final int val = (int) (Math.random() * 10) + 1; // PB
         final JProgressBar progressBar = new JProgressBar(0, 100 * val); // PB
         progressBar.setStringPainted(true);
         Border border = BorderFactory.createTitledBorder("Reading...");
         progressBar.setBorder(border);
         content.add(progressBar, BorderLayout.NORTH);
         jProgFrame.setSize(300, 100);
         jProgFrame.setVisible(true);
         // PB
         final Thread longTask = new Thread() {
             private int counter = 0;
             public void run() {
              for (int i = 0; i <= 100; i++) {
                  counter += val;
                  javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                       progressBar.setValue(counter);
                  try {
                   Thread.sleep(100); // PB
                  } catch (InterruptedException e) {
         longTask.start();
         // PB
         Thread followUpTask = new Thread(new Runnable() {
             @Override
             public void run() {
              try {
                  System.out.println("Follow up task is waiting");
                  longTask.join();
                  System.out.println("Follow up task  continues");
              } catch (InterruptedException e) {
                  e.printStackTrace();
         followUpTask.start();
        public static void main(String[] args) {
         SwingUtilities.invokeLater(new Runnable() {
             public void run() {
              new ProblemCode();
    }Piet

  • Random returning same values for all threads?

    <p>I "translated" an Applet example from a book to a MIDlet (as part of my learning process). However the MIDlet does not react as it should, and when the particles are all moving independently in the Applet, they are stuck together (as one) in the MIDlet.</p>
    <p>So far, only one possibility was suggested to me: if the Random object are created one after the other, they could end up based on the same seed (which is the clock by default) and will generate the same numbers.</p>
    <p>I tried to delay between the creation of the threads with no result. And the fact that the applet runs properly makes me wonder...</p>
    <p>Does anyone have a clue?</p>
    <p>In the MIDlet:</p>
    protected Thread makeThread(final Particle p) { // utility
        Runnable runloop = new Runnable() {
          public void run() {
            try {
              for(;;) {
                p.move();
                canvas.repaint();
                Thread.sleep(100); // 100msec is arbitrary
            catch (InterruptedException e) {  return; }
        return new Thread(runloop);
      }<p>In the particle:</p>
    protected final Random rng = new Random();
      public synchronized void move() {
        x += rng.nextInt(step) - (step/2);
        y += rng.nextInt(step) - (step/2);
        //returns exactly the same 10 times in a row
      }

    You might try justing just one static Random object.
    Also note that als long as your using CLDC 1.0, you don't have any floating point support.

  • Force textInput to wait for all characters?

    I have a problem with getting text from a text box before the text entry is complete.
    Here's the issue: I am using a speech-recognition program to convert spoken words to typed text; thus, when I speak a word, it is typed (like via keyboard) into a TextInput field. 
    I would like the program to "check" the text in this TextInput when a spacebar keyboard down event is triggered.  So I've tried adding a keyboard event listener like so:
    typedInput.addEventListener(KeyboardEvent.KEY_DOWN, checkKey) // turn on keyboard listener
    private function checkKey(keypress:KeyboardEvent):void { // handle keypress triggers
    if (keypress.keyCode == 32) {
         // if spacebar is pressed, check the text of the input box to see if it is correct
         if (typedInput.text == nextWord)  trace("Successful word match! Typed input: "+typedInput.text);
         else
         // if incorrect, highlight the word in orange; if already orange, highlight in red and call the word audio
         trace ("Incorrect spoken word. Typed input: "+typedInput.text);
    typedInput.text = "";
    So basically it should check the TextInput and compare against a string, once spacebar is pressed.
    The problem is... the results are sporadic; sometimes it triggers the spacebar event before being able to get any text in the input; sometimes it might grab the first letter or two.
    Another problem might be that this event listener is listening to EVERY keystroke when all I really care about is listening for the spacebar.
    I've tried adding the keyboard event listener to the state instead of the text input, but it doesn't seem to make any difference.
    Any ideas on how to get this to work? I'm going to see if I can use my third-party program (GlovePIE) to map spacebar to enter key instead, and then be able to use the "enter" event for the textinput, but otherwise I'm at a loss... either it's taking too long because it has to check every keystroke, or the keystrokes are coming so fast that the event handler is finished before the text input element can even register that it has been input.
    Would it be better to use a "change" event on the text handler? If so, how would I go about checking each new character typed into the input?

    Hmm, I got it to work okay by using a timer to force a wait, like so:
    private function checkKey(keypress:KeyboardEvent):void {
    if (keypress.keyCode == 32) {
    // if spacebar is pressed, check the text of the input box to see if it is correct
    var timer:Timer = new Timer(10,1);
    timer.addEventListener(TimerEvent.TIMER_COMPLETE, timeupHandler);
    timer.start();
    function timeupHandler(event:TimerEvent):void {
         if (typedInput.text == nextWord) {
         // if correct, change color of the word and increment to the next word on the page
         trace("Successful spoken word match! Typed input: "+typedInput.text);
         else {
         // if incorrect, highlight the word in orange; if already orange, highlight in red and call the word audio
         trace ("Incorrect spoken word. Typed input: "+typedInput.text);
         typedInput.text = "";
    However, this really seems like a hack that I'd like to avoid -- for one thing, I don't want to slow down the system any more than necessary (ie. if it only takes 3 milliseconds to get all the letters in place, why wait 10 every time?), and for another it seems like it would be machine-dependent (processor, etc.)  So this is a hack, not a real solution (unless there is no better solution)
    I will try converting spacebar to enter and see how that works with an "enter" listener on the input.  (But even this will create a small amount of lag)

  • "expand role" nt waiting for all users in the role to view the notification

    I have created adhoc roles using the following code.
    lv_user_list_txt := 'SYSTECH'||','||'FNATECH';
    wf_directory.createadhocrole (lv_role_name_txt, lv_role_display_txt);
    wf_directory.adduserstoadhocrole (lv_role_name_txt, lv_user_list_txt);
    I have assigned it to the Item attribute of type 'Role' using the following code.
    wf_engine.setitemattrtext (
    itemtype => itemtype,
    itemkey => itemkey,
    aname => 'LIST_OF_APPROVER',
    avalue => lv_role_name_txt
    I have checked the 'Expand role' check box in the notification and assigned the performer as the Item attribute(Role type) 'LIST_OF_APPROVER'.
    But when one user in the role approves or rejects, the notification of the other user is cancelled. the other user can no longer view the notification.
    Ideally, after checking the 'Expand role', the workflow should not proceed to the next node until, all the user have performed an action. But this is not happening. Please help on this :(
    Thanks in Advance.
    Anitha.

    yes, I did. I spent at least 8 hours searching for a solution here, in the forums and tried everything making sense... The EFI downgrade was the only thing that helped.
    My personal opinion is: Apple should offer the EFI downgrade option to all users in an official way. It looks like my favorite vendor does not want to admit they made a hardware+software mistake (the EFI 1.7 update solves some HDD issues on some new MBPs but causes other problems on other MBPs).
    Message was edited by: Bartek Bargiel

  • Waiting for multiple threads?

    I'm currently writing an app which, when a user opens a GUI screen, several threads are created which go away to load data. A "loading..." message should be displayed until all loading threads have completed.
    What's the best way to implement this?

    Ah yes. I was doing that, ish, but was doing:
    t1.start();
    t1.join();
    t2.start();
    t2.join();
    But of course it should have been:
    t1.start();
    t2.start();
    t1.join();
    t2.join();
    Cool, thanks!

  • Dbx collector not collecting data for all threads

    Hi, I am having problem with the dbx collector when I collect data from a multithreaded application. Data seems to be collected only from the first threads. Sun Studio 11
    (dbx) attach -p 5501 my_proc
    (dbx) threads
    > t@2 a l@2 SI_SigThr() running in ___sigtimedwait()
    t@3 a l@3 SF_autoReInit() running in ___nanosleep()
    t@4 b l@4 SF_sendHeartBeats() running in ___nanosleep()
    t@5 a l@5 SF_Main() running in ___nanosleep()
    t@6 a l@6 MSI_TimerThread() running in ___nanosleep()
    t@7 b l@7 HbtMonitor() running in ___nanosleep()
    t@20 b l@20 umem_update_thread() sleep on 0xfe803ea8 in __lwp_park()
    t@22 a l@22 FXI_SorterSpooler() sleep on 0xbd418 in __lwp_park()
    t@23 a l@23 XCI_ReaderThread() running in __pollsys()
    t@24 a l@24 MSI_ListenerThread() running in soaccept()
    t@25 a l@25 MSI_ListenerThread() running in soaccept()
    ... and so on.... (sever hundred threads)
    t@33 a l@33 ReconnectingThread() sleep on 0xc55f8 in __lwp_park()
    ... and so on.... (sever hundred threads)
    (dbx) collector limit unlimited
    (dbx) collector enable
    (dbx) cont
    ^C
    (dbx) collector show
    collector enable
    collector profile timer 10.007
    collector profile on
    collector synctrace threshold calibrate
    collector synctrace off
    collector hwprofile counter insts
    collector hwprofile off
    collector heaptrace off
    collector mpitrace off
    collector store directory "."
    collector store experiment "test.3.er"
    collector sample periodic
    collector dbxsample on
    collector sample period 1
    collector limit none
    collector archive on
    (dbx) collector disable
    When viewing the experiment only the t@2,t@3,t@4 and t@33 are seen!?
    What

    I had a few other questions in my earlier post.
    During the time that data collection was running, how active (w.r.t. CPU time) should those threads be? When you run collect (instead of DBX) and look at timeline, how much activity do you see activity on the 'missing' threads during the similar segment (and loading) of the program's operation ? (I believe the collector won't record data if a thread does not get sufficient CPU time during the data collection period. )
    Also, please post which OS version you are using and which version of collect & dbx. Thanks!

  • Waiting the main thread till all child thread has completed

    I am in the process of developing a batch application in Java 5.0 which extensively uses the java.util.concurrency API. Here is a small description of what the batch process will do,
    1. Retrieve values from DB and populate a blocking queue in main thread.
    2. Instantiate a Threadpool by calling, Executors.newFixedThreadPool(2)
    3. Invoking the following block of code from the main thread,
    while(!iBlockingQueue.isEmpty()) {
        AbstractProcessor lProcessor = new  DefaultProcessor((BusinessObject)iBlockingQueue.remove());
        iThreadPool.execute(lProcessor);
    }DefaultProcessor is a class that extends Thread.
    4. Invoking the following block of code from the main thread,
    iThreadPool.shutdown();
    try {
         iThreadPool.awaitTermination(30, TimeUnit.SECONDS);
         } catch (InterruptedException interruptedException) {
              iLogger.debug("Error in await termination...", interruptedException);
    Since, this is the first time I am using the java.util.concurrency API, I want to know whether this is the right way to wait for all the child threads to complete before executing further statements in the main (parent) thread. Or do I necessariliy have to call join() to ensure that the main thread waits for all the child threads to finish which can only happen when the queue is empty.
    Please note here that as per the requirements of the application the blocking queue is filled only once at the very beginning.
    I will appreciate any inputs on this.
    Thanks.

    looks like you would be waiting on a queue twice, once in the loop and again, under the hood, in the threadpool's execute()
    the threadpool's internal queue is all that is needed
    if your iBlockingQueue is also the threadpool's internal queue, you might have a problem when you remove() the BusinessObject
    by making DefaultProcessor extend Thread you are, in effect, implementing your own threadpool without the pooling
    DefaultProcessor need only implement Runnable, it will be wrapped in a thread within the pool and start() called
    to implement a clean shutdown, I suggest writing DefaultProcessor.run() as an infinite loop around the blocking queue poll(timeout) and a stop flag that is checked before going back to poll
    class DefaultProcessor implements Runnable {
      private BlockingQueue myQ;
      private boolean myStopFlag;
      DefaultProcessor( BlockingQueue bq ) { myQ = bq; }
      public void run() {
        BusinessObject bo = null;
        while( !myStopFlag && (bo=myQ.poll( 10, SECONDS )) ) {
          // business code here
      public void stop() { myStopFlag = true; }
    } Now, after iThreadPool.shutdown(), either call stop() on all DefaultProcessors (or alternatively send "poison" messages to the queue), and give yourself enough time to allow processing to finish.

Maybe you are looking for

  • Why objet is not stopped when page change

    Hi, I'm currently working in my company on a library. A have created a class to display ads in a webrowser. A request is executed every 20 seconds. I display the ads in a panorama page but when i go to a detail page my banner continu to do request. T

  • Failure to authorize third party plug-ins with 7.1.1

    I am running 10.4.2 on a new g5. I just upgraded to 7.1.1 from 7.0.1 and I get multiple crashes on the authorization of the plug-ins. I got the message "the application auval quit unexpectedly" numerous times. I also got another message about missing

  • OraOLEDB.Oracle versus msdaora provider for adParamInputOutput

    I'm currently using Microsoft OLE DB for Oracle provided with MDAC2.8 to execute stored procedures in an ASP page. My vbscript procedure contains an adParamInputOutput parameter (see code below - prm pio_session_id). Everything works fine. I pass a v

  • CIN - RG23D

    Hi, One of my client having Trading Registration.Have to follow RG23D register.But, they receive the input material as ROH, do some additional process and sale as Output material FERT.During purchasing i capturing excise in J1ig.During sales process

  • Encore installed but no buttons or photo objects appear. Where do I load these?

    I recently purchased CC Premier CS6 and I am going through the Lynda.com tutorial on how to use Encore and when it says select a Blank HD menu there are not buttons or photo objects available. Also, it will not allow me to import a custom button. Any