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

Similar Messages

  • Media Recovery Waiting for thread 1 sequence (in transit)

    I have rebuilt our standby database using an rman duplicate since it was missing many archive logs.
    Following the duplicate, the standby is now almost in sync with the primary. Logs are shipping across but are not being applied in a timely manner. How long should it take for an archive log from the primary to be applied to the standby?
    I need to know this so that a proper script can be set up to check the primary and standby. At the moment they are never exactly in sync - always one sequence number behind the primary.
    Why is the standby is not applying in a timely manner?
    From the alert log:
    Media Recovery Waiting for thread 1 sequence 11278 (in transit)
    The log seems to be "in transit" for a long time
    PRIMARY:
    SQL> select max (sequence#) current_seq from v$log;
    CURRENT_SEQ
    11278
    SB:
    SQL> select MAX (SEQUENCE#), APPLIED FROM V$ARCHIVED_LOG where APPLIED ='YES' GROUP BY APPLIED;
    MAX(SEQUENCE#) APP
    11277 YES
    ALERT LOG:
    RFS[2]: Archived Log: '/backup/prod/log_1_11277_704816194.dbf'
    Primary database is in MAXIMUM PERFORMANCE mode
    Mon Nov 1 15:22:01 2010
    Media Recovery Log /backup/prod/log_1_11272_704816194.dbf
    Mon Nov 1 15:26:49 2010
    Media Recovery Log /backup/prod/log_1_11273_704816194.dbf
    Mon Nov 1 15:29:54 2010
    Media Recovery Log /backup/prod/log_1_11274_704816194.dbf
    Mon Nov 1 15:34:18 2010
    Media Recovery Log /backup/prod/log_1_11275_704816194.dbf
    Mon Nov 1 15:36:42 2010
    Media Recovery Log /backup/prod/log_1_11276_704816194.dbf
    Mon Nov 1 15:39:43 2010
    Media Recovery Log /backup/prod/log_1_11277_704816194.dbf
    Mon Nov 1 15:42:34 2010
    Media Recovery Waiting for thread 1 sequence 11278 (in transit)
    I should add that I understand that for the Primary and Standby to be out by one log is not cause for concern (they are applying). Its just that I wanted to script a check that would compare them both, and and the moment they are never equal - when I understand that they should be and that the logs should be applied almost immediately.
    Edited by: Dan A on Nov 1, 2010 4:36 PM

    How long should it take for an archive log from the primary to be applied to the standby?depends on network speed also.
    make sure the archives are shipped to standby location.
    PRIMARY:
    SQL> select max (sequence#) current_seq from v$log;
    CURRENT_SEQ
    11278(this is log not archivelog ) ..... :)SB:
    SQL> select MAX (SEQUENCE#), APPLIED FROM V$ARCHIVED_LOG where APPLIED ='YES' GROUP BY APPLIED;
    MAX(SEQUENCE#) APP
    11277 YES
    Hi check is MRP started or not?
    primary database you need not check current sequence, check last generated sequence..not current sequence.
    current sequence is redo log which has been not yet archived
    I think everything is perfect here.. no issues.
    Hope you understood, let me know if not clear , thanks.

  • Standby MRP0 process- Wait for Log

    Hi ,
    I have standby Oracle 11.2.0.3 DB on  AIx  server .
    After configuring Dataguard Log apply service fails on standby DB ..Following is resulf from my standy and primary DB .
    On Primary
    select process, status, sequence#, block# from v$managed_standby;
    PROCESS   STATUS        SEQUENCE#     BLOCK#
    ARCH      CLOSING              52          1
    ARCH      CLOSING              51          1
    ARCH      WRITING               2      38913
    ARCH      CLOSING              52          1
    LNS       WRITING              54       1003
    On Standby
    select process, status, sequence#, block# from v$managed_standby;
    PROCESS   STATUS        SEQUENCE#     BLOCK#
    ARCH      CONNECTED             0          0
    ARCH      CONNECTED             0          0
    ARCH      CONNECTED             0          0
    ARCH      CONNECTED             0          0
    RFS       RECEIVING                  2       6145
    RFS       IDLE                              54      1025
    RFS       IDLE                              0          0
    MRP0      WAIT_FOR_LOG      2          0
    On primaray Datagaurd status shows below output
    select  message from  V$DATAGUARD_STATUS order by TIMESTAMP;
    ARCH: Completed archiving thread 1 sequence 53 (1093671-1094088)
    ARCH: Beginning to archive thread 1 sequence 53 (1093671-1094088)
    LNS: Beginning to archive log 3 thread 1 sequence 54
    MESSAGE
    LNS: Completed archiving log 2 thread 1 sequence 53
    On Standby DB
    select  message from  V$DATAGUARD_STATUS order by TIMESTAMP;
    MESSAGE
    RFS[2]: Assigned to RFS process 659510
    RFS[2]: No standby redo logfiles available for thread 1
    RFS[3]: Assigned to RFS process 1110268
    RFS[3]: No standby redo logfiles available for thread 1
    Attempt to start background Managed Standby Recovery process
    MRP0: Background Managed Standby Recovery process started
    Managed Standby Recovery starting Real Time Apply
    Media Recovery Waiting for thread 1 sequence 2 (in transit)
    Please let me know what needs ti change for start log apply on physical standby .
    Thanks .
    Vaishali.

    Hi Shivananda,
    Please find below output ..
    I can tnsping both the database as well as when i try to connect from sqlplus to DB ..it was sucessful from both the side ...
    SQL> select severity,error_code,message from v$dataguard_status where dest_id=2;
    SEVERITY      ERROR_CODE
    MESSAGE
    Error               1034
    PING[ARC2]: Heartbeat failed to connect to standby 'IHISDR'. Error is 1034.
    Error               1034
    FAL[server, ARC2]: Error 1034 creating remote archivelog file 'IHISDR'
    Error               1089
    FAL[server, ARC2]: FAL archival, error 1089 closing archivelog file 'IHISDR'
    SEVERITY      ERROR_CODE
    MESSAGE
    Warning             1089
    LNS: Attempting destination LOG_ARCHIVE_DEST_2 network reconnect (1089)
    Warning             1089
    LNS: Destination LOG_ARCHIVE_DEST_2 network reconnect abandoned
    Error               1089
    Error 1089 for archive log file 1 to 'IHISDR'
    SEVERITY      ERROR_CODE
    MESSAGE
    Error               1089
    FAL[server, ARC0]: FAL archival, error 1089 closing archivelog file 'IHISDR'
    7 rows selected.
    Thanks .

  • RMAN Restore Error - media recovery requesting unknown log: thread 1 seq 7

    Im using RMAN to copy a database to another server. The new server is IDENTICAL to the old one. By identical I mean it has the same sever name, ip address, operating system, Oracle version and directory structure.
    The new server already has the instance created, (same name as the old server instance, paths etc)
    The backup files have been manually restored to the new server, same locations as they were on the old one. ( RMAN did an automatic controlfile backup and also the archivelogs on the old server ).
    Ive restored the control file on the new server from the RMAN backup pieces.
    Ive catalogued the RMAN backup pieces on the new server.
    I know the last sequence available in the archivelogs backup by running on the new server :
    list backup of archivelog all;
    List of Backup Sets
    ===================
    BS Key Size Device Type Elapsed Time Completion Time
    5 14.43M DISK 00:00:03 11-MAY-11
    BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20110511T163502
    Piece Name: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\SAT\BACKUPSET\
    011_05_11\O1_MF_ANNNN_TAG20110511T163502_6WOC5833_.BKP
    List of Archived Logs in backup set 5
    Thrd Seq Low SCN Low Time Next SCN Next Time
    1 2 550217 10-MAY-11 556559 11-MAY-11
    1 3 556559 11-MAY-11 559776 11-MAY-11
    1 4 559776 11-MAY-11 560093 11-MAY-11
    1 5 560093 11-MAY-11 560794 11-MAY-11
    BS Key Size Device Type Elapsed Time Completion Time
    7 15.50K DISK 00:00:01 11-MAY-11
    BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20110511T163653
    Piece Name: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\SAT\BACKUPSET\
    011_05_11\O1_MF_ANNNN_TAG20110511T163653_6WOC8PMP_.BKP
    List of Archived Logs in backup set 7
    Thrd Seq Low SCN Low Time Next SCN Next Time
    1 6 560794 11-MAY-11 560851 11-MAY-11
    So far its all going swimmingly well.
    Now I want to restore the datafiles and recover. So I ran :
    RMAN run { restore database; recover database; alter database open resetlogs; }
    This gave me the output below which goes great but I get a final error, I think the error is because its looking for an archive log thats not in the backup set, but it should be. However, I think SCN 560851 is for a log that hadnt been created yet on the old server when the backup was ran ?
    How do I address resolving the error ? Its worth pointing out log, "archive log filename=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\SAT\ARCHIVELOG
    \2011_05_11\O1_MF_1_6_6WOK1X4W_.ARC recid=10 stamp=750881741" isnt on the old server either which is why its not in the backup set.
    I can do a alter database open reset logs but Id prefer to know why its failing.
    Any help would be much appreciated.
    RMAN> run { restore database; recover database; alter database open resetlogs; }
    Starting restore at 11-MAY-11
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile backupset restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    restoring datafile 00001 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\SAT\SYSTEM01.DBF
    restoring datafile 00002 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\SAT\UNDOTBS01.DBF
    restoring datafile 00003 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\SAT\SYSAUX01.DBF
    restoring datafile 00004 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\SAT\USERS01.DBF
    channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\10.2.0\FLASH_REC
    OVERY_AREA\SAT\BACKUPSET\2011_05_11\O1_MF_NNNDF_TAG20110511T163507_6WOC5CM7_.BKP
    channel ORA_DISK_1: restored backup piece 1
    piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\SAT\BACKUPSET\2011_05_
    11\O1_MF_NNNDF_TAG20110511T163507_6WOC5CM7_.BKP tag=TAG20110511T163507
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
    Finished restore at 11-MAY-11
    Starting recover at 11-MAY-11
    using channel ORA_DISK_1
    starting media recovery
    channel ORA_DISK_1: starting archive log restore to default destination
    channel ORA_DISK_1: restoring archive log
    archive log thread=1 sequence=6
    channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\10.2.0\FLASH_REC
    OVERY_AREA\SAT\BACKUPSET\2011_05_11\O1_MF_ANNNN_TAG20110511T163653_6WOC8PMP_.BKP
    channel ORA_DISK_1: restored backup piece 1
    piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\SAT\BACKUPSET\2011_05_
    11\O1_MF_ANNNN_TAG20110511T163653_6WOC8PMP_.BKP tag=TAG20110511T163653
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    archive log filename=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\SAT\ARCHIVELOG
    \2011_05_11\O1_MF_1_6_6WOK1X4W_.ARC thread=1 sequence=6
    channel default: deleting archive log(s)
    archive log filename=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\SAT\ARCHIVELOG
    \2011_05_11\O1_MF_1_6_6WOK1X4W_.ARC recid=10 stamp=750881741
    unable to find archive log
    archive log thread=1 sequence=7
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of recover command at 05/11/2011 18:15:42
    RMAN-06054: media recovery requesting unknown log: thread 1 seq 7 lowscn 560851
    RMAN>
    Edited by: user12173666 on 11-May-2011 10:28

    You need to do incomplete recovery i.e. to ask RMAN to restore/recover to some specific point in time. This is usually done with some UNTIL clause or SET UNTIL statement. Example in your case:
    SET UNTIL SEQUENCE 7;See http://download.oracle.com/docs/cd/B19306_01/backup.102/b14194/rcmsynta065.htm#RCMRF160.

  • 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

  • Standby redo log group for particular thread

    hi masters,
    actually i am performing an experiment to create physical standbyt database on the same machine as my primary database.
    i ma going according to 'data guard admin guide'. while section for ading standby redo log group,it says that you have to add standby redo log group to "thread"....
    what is this thread? and how can i foind to which thread i have to assign the next redo log group??
    how can i find current thread??
    what if i dont add "to thread' clause in my statement:-
    ALTER DATABASE ADD STANDBY LOGFILE THREAD 5
    2> ('/oracle/dbs/log1c.rdo','/oracle/dbs/log2c.rdo') SIZE 500M;
    thanks and regards
    VD

    Vikrant,
    First a question: Do you have a RAC instance? If so the paragraph even doesn't apply to you and I'm not sure why you are questioning it.
    Secondly
    "The THREAD clause is required only if you want to add one or more standby redo log
    file groups to a specific primary database thread. If you do not include the THREAD
    clause and the configuration uses Real Application Clusters (RAC), Data Guard will
    automatically assign standby redo log file groups to threads at runtime as they are
    needed by the various RAC instances."
    this means you dont have to specify thread for RAC,as it will allocate one according to current thread.
    Your conclusion is incorrect.
    Where do you read the word 'current'?
    Oracle will likely simply make sure each instance has sufficient standby redolog groups, the requirement is 1 standby redolog group per group + 1 extra.
    Sybrand Bakker
    Senior Oracle DBA

  • Cisco Media Hub - Waiting for Media Information on the web application

    Good afternoon, I just installed the Media Hub on my Mac. I find the flac music on the media hub through the finder and the web application from media hub (in the configuration settings). Until now I don't see any information concerning the songs on the web application itself (they say that one has to wait several hours until the refresh process of the web application is through). I use kinsky desktop for my hifi (linn majic ds) and the MplayerX on my Mac.
    - Does anyone has the same problems with waiting for the update of the media information on the web application
    - Which software do you recommend for managing your media (mp3, wmv, flac)
    Many thanks for your feedback, A.

    Hi Archimedes76,
        I use windows media player to manage my music files. Regarding your music file info issue, sometimes I do have to restart my media hub so that it'll re-index the files especially if I transferred a lot of new media. If after a restart and waiting for a few hours while the media rescan and reindex files doesn't work for you then you might try to read this. I found it on the linksys support page though the example shown there is  a windows PC.
         Hope this helps!

  • 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

  • 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.

  • 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

  • Screen lock activating immediately instead of waiting for inactivity

    I have activated Screen Lock so that it requires a password when waking from sleep after 1 hour of inactivity. The problem is that it requires the password immediately no matter how long the computer has been inactive. Screen lock seems to not be waiting the proper time before activating. There must be some sort of bug because anytime the screen lock activates sooner than the selected 1 hour, all i have to do is hit the cancel (X) button at the bottom of the lock screen and my display will go back to sleep and then moving the cursor will wake the computer without requiring password...So Weird!

    Screen Lock is not related to inactivity.  It is realted to Sleep or Screen Saver starting.  So if the Mac is put to sleep, or the Screen Saver is activated, then you will need to enter your password to unlock the screen.
    In System Preferences -> Security -> General you can specify a delay after Screen Saver or Sleep is started before the password is required, in case the screen saver starts and you quickly move the mouse to kill it.  I use 5 seconds.  But this is not idle related, just start of sleep or start of screen saver.
    System Preferences -> Desktop & Screen Saver allows you to specify when to start after the system has been idle/inactive.
    It is possible you have used mixed terms which are confusing me, so if you could clarify, that would be helpful.

  • RMAN-06054: media recovery requesting unknown log: thread 1 seq 300 lowscn

    Got it dropped and recretaed - dont know why didnt work
    Edited by: user3489571 on 14-Apr-2010 18:46

    The ALTER DATABASE REGISTER LOGFILE command in SQLPlus is for Standby and Streams implementation.
    You should be using the CATALOG command in RMAN.

  • 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!

Maybe you are looking for

  • Problem importing a table with data in an existing schema

    Hi, I am trying to import a schema and found an error while importing ORA-39083: Object type TABLE failed to create with error: ORA-01843: not a valid month Failing sql is: CREATE TABLE "AMBERSAP"."QUOTE" ("QUOTE_ID" VARCHAR2(15) NOT NULL ENABLE, "CO

  • Bank interface

    Hi all, We have a requirement of creating a citidirect interface format for sending the payment details of the employee to citibank.  Should we require ABAP programming for this? Is there any format existing in SAP to copy and change the format.  Ple

  • I get ads on websites that aren't there when I use IE or a different computer.

    When using Firefox on Facebook, I get ads that are all over the place on facebook and other websites I normally visit nearly daily. However, using Internet Explorer or other computers and visit the same websites, I don't get the ads issues. I've also

  • Time Machine doesn't backup

    I get this message "Time Machine has not backed up for x days." It doesn't give any error message or anything else. I don't know how to trouble shoot this. I would greatly appreciate help. I don't see another message like this. I look in Time Machine

  • Write Back - Database update logs user out

    Hi All, I have implemented write back functionality on a single varchar field in one of my reports. Everything appears to be setup correctly (permissions are set at the presentation and rpd layer to allow for the write back and the write back templat