DBMS_SCHEDULER wait for job/program to finish

Hello All,
I've run into a little limitation on my understanding of DBMS_SCHEDULER.
I have an executable script which does a network scan. My goal is to lauch this from an application, and wait (could be 5 minutes or 2 hours) for the scan to finish before I return the results.
Where I'm a little confused, is the flow of the entire process works when I want to wait for the program to complete:
1 - Define a program?
2 - Apply arguments?
3 - Apply credentials
4 - Define a chain?
Literally, I'm not sure how to tackle this task. I simply wish to launch to job and wait for it to finish before I go retreive the file from the server. This is what I have so far, just bits and pieces.
Mayeb I simply missed somethign in the docs, and I'm overcomplicate things.
Thanks in advance to the community for you assistance.
Jan S.
BEGIN
  dbms_scheduler.create_program(
    program_name   => 'network_scan',
    program_type   => 'executable',
    number_of_arguments => 5,
    program_action => 'scan_network.py',
    enabled        =>  FALSE);
  dbms_scheduler.define_program_argument('network_scan',1,'x01=1');
  dbms_scheduler.define_program_argument('network_scan',2,'x02=192.168.1.1');
  dbms_scheduler.define_program_argument('network_scan',3,'x03=24');
  dbms_scheduler.define_program_argument('network_scan',4,'x04=D');
  dbms_scheduler.define_program_argument('network_scan',5,'x05=1521-1523,7777'); 
  vJobName := dbms_scheduler.generate_job_name('NET_SCAN_');
  dbms_scheduler.create_job(job_name => vJobName,
                              job_type => 'EXECUTABLE',
                              job_action => '/usr/bin/scan_nework.sh',
                              number_of_arguments => 5,
                              enabled => FALSE,
                              auto_drop => FALSE,
                              comments => 'Network');
dbms_scheduler.set_attribute(vJobName,'credential_name', 'SUCREDENTIALS');
  dbms_scheduler.run_job(vJobName,FALSE);
  dbms_scheduler.create_chain (
   chain_name            =>  'net_scan_chain',
   rule_set_name         =>  NULL,
   evaluation_interval   =>  NULL,
   comments              =>  NULL);
  dbms_scheduler.define_chain_step('net_scan_chain', 'step1', 'network_scan');
  SELECT additional_info, external_log_id
  INTO   l_additional_info, l_external_log_id
  FROM   (SELECT log_id,
                 additional_info,
                 REGEXP_SUBSTR(additional_info,'job[_0-9]*') AS external_log_id
          FROM   dba_scheduler_job_run_details
          WHERE  job_name = vJobName
          ORDER BY log_id DESC)
  WHERE  ROWNUM = 1;
  DBMS_OUTPUT.put_line('ADDITIONAL_INFO: ' || l_additional_info);
  DBMS_OUTPUT.put_line('EXTERNAL_LOG_ID: ' || l_external_log_id); 
  -- Wait at least 3 second because its distributed
  dbms_lock.sleep(3);
  SELECT job_name, status, error#, additional_info
  FROM dba_scheduler_job_run_details
  WHERE job_name= vJobName;
  dbms_lob.createtemporary(l_clob, FALSE);
  dbms_scheduler.get_file(
    source_file     => l_external_log_id ||'_stdout',
    credential_name => 'ORACLECREDENTIALS',
    file_contents   => l_clob,
    source_host     => NULL);
  DBMS_OUTPUT.put_line('stdout:');
  DBMS_OUTPUT.put_line(l_clob);
k Scan');

See Tom's last reply in this AskTom thread. It shows how to use the DBMS_ALERT package to signal you.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5320945700346034393

Similar Messages

  • When server start, get "Waiting for another script to finish..." message and doesn't go anywhere.

    Hello, my engineer (Japanese) is trying to start AdobeMediaServer but he got stuck after getting "Waiting for another script to finish..." message. Any idea how to resolve this situation?
    [root@NA1SIBZDH02 /opt/adobe/ams]# ./server start
    NPTL 2.5
    chmod: changing permissions of `./tmp/': 読み込み専用ファイルシステムです
    Waiting for another script to finish...
    [root@NA1SIBZDH02 /opt/adobe/ams]#
    [root@NA1SIBZDH02 /opt/adobe/ams]#
    [root@NA1SIBZDH02 /opt/adobe/ams]# ls -l
    合計 52324
    drwxr-xr-x 15 ams  ams      4096  9月 11 17:54 Apache2.2
    -rwxr-xr-x  1 root root  1061035  9月 11 17:54 License.htm
    -rwxr-xr-x  1 root root    43374  9月 11 17:54 License.txt
    -rwxr-xr-x  1 root root    58827  9月 11 17:54 ReleaseNotes.htm
    -rwxr-xr-x  1 root root     5715  9月 11 17:54 adminserver
    -rwxr-xr-x  1 root root      871  9月 11 17:54 adobe-lq.png
    -rwxr-xr-x  1 root root     2912  9月 11 17:54 ams_icon.png
    -rwxr-xr-x  1 root root  3220552  9月 11 17:54 amsadmin
    -rw-r--r--  1 root root        6  9月 11 17:54 amsadmin.pid
    -rwxr-xr-x  1 root root 11187664  9月 11 17:54 amscore
    -rwxr-xr-x  1 root root  4331472  9月 11 17:54 amsedge
    -rwxr-xr-x  1 root root  3070840  9月 11 17:54 amsmaster
    -rw-r--r--  1 root root        6  9月 11 17:54 amsmaster.pid
    -rwxr-xr-x  1 root root     5242  9月 11 17:54 amsmgr
    drwxrwxrwx  6 ams  ams      4096  9月 11 17:54 applications
    -rwxr-xr-x  1 root root      960  9月 11 17:54 cleanup
    drwxr-x---  3 ams  ams      4096  9月 11 17:54 conf
    drwxr-xr-x  5 ams  ams      4096  9月 11 17:54 creds
    drwxr-xr-x  3 root root     4096  9月 11 17:54 documentation
    -rwxr-xr-x  1 root root 16368842  9月 11 17:54 libadbe_dme.so
    -rwxr-xr-x  1 root root   336065  9月 11 17:54 libadbe_flv.so
    -rwxr-xr-x  1 root root    59248  9月 11 17:54 libasneu.so.1
    -rwxr-xr-x  1 root root    71263  9月 11 17:54 libcares.so
    -rwxr-xr-x  1 root root    71263  9月 11 17:54 libcares.so.2
    -rwxr-xr-x  1 root root    71263  9月 11 17:54 libcares.so.2.0.0
    -rwxr-xr-x  1 root root  1968482  9月 11 17:54 libcrypto.so.1.0.0
    -rwxr-xr-x  1 root root   162403  9月 11 17:54 libexpat.so.1
    -rwxr-xr-x  1 root root  3497472  9月 11 17:54 libfmsccme.so
    -rwxr-xr-x  1 root root  6992879  9月 11 17:54 libhds.so
    -rwxr-xr-x  1 root root   403767  9月 11 17:54 libssl.so.1.0.0
    drwxr-xr-x  2 root root     4096  9月 11 17:54 licenses
    drwxrwxrwx  2 root root     4096  9月 11 17:54 logs
    drwxr-xr-x  5 root root     4096  9月 11 17:54 modules
    drwxr-xr-x  6 root root     4096  9月 11 17:54 samples
    drwxr-xr-x  3 root root     4096  9月 11 17:54 scriptlib
    -rwxr-xr-x  1 root root     7494  9月 11 17:54 server
    -rwxr-xr-x  1 root root   300864  9月 11 17:54 shmrd
    -rwxr-xr-x  1 root root    36206  9月 11 17:54 tcSrvMsg
    drwxrwxrwx  2 root root     4096  9月 11 17:54 tmp
    drwxr-xr-x  9 root root     4096  9月 11 17:54 tools
    -rwxr-xr-x  1 root root     2411  9月 11 17:54 uninstallAMS
    drwxr-xr-x  8 ams  ams      4096  9月 11 17:54 webroot
    [root@NA1SIBZDH02 /opt/adobe/ams]#
    [root@NA1SIBZDH02 /opt/adobe/ams]#
    ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

    A possible cause is security software (firewall) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.<br />
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    * https://support.mozilla.com/kb/Server+not+found
    * https://support.mozilla.com/kb/Firewalls

  • Compressor 4.1.3 hangs Waiting for Create Disc to Finish

    Compressor 4.1.3 hangs at the "Waiting for Create Disc to Finish" stage.  The audio and video streams have been created and are in Finder. The correct drive has been selected in the Actions section and there is a disk in the drive. I have run Compressor Repair.  However there is no activity at the drive (which otherwise works fine and will burn a disk from Finder).  Anyone any ideas?

    I'e not run into this before. Try a different clip – preferably a QuickTime movie. Bring that into Compressor and mark a short section with in and out points. Choose Hard Drive for Output Device in the Job Action section. What happens after you submit it?
    Russ

  • Message "waiting for job to complete..." for printing

    Hello,
    I have a printer installed on Windows Server 2008 R2, shared for a
    windows 7 computer (OK), and a Macbook Air 10.8.3. m.lyon. (KO) is installed and configured correctly. HP Deskjet 3940.
    But in the MacBook when I print any document send the form to the
    Windows tail, and appears well in line, even tells me not just printing but printing ever, life is printing but printing out the document, including the correct printer makes noise as to be printed but nothing .
    On the MacBook print queue the message remains "printing: waiting for job to complete ..." and never complete.
    I install the printer on the Windows icon in Printers & Scanners for smb
    for the default printer and the result is always the same.
    Connect the printer directly to a USB port on the MacBook to try and charge good drivers and printed the first ....
    I need help, can you help,
    thanks,
    Joan.

    I solved this as follows....
    Go to the Windows computer.
    Open printers and select the printer
    Go to Customize your printer
    Go to ports
    Disable "Enable Birectional Support" in the Ports
    Sounds crazy, but it worked.
    Good luck, YMMV.

  • Remotely invoke DS job and wait for job

    Hi,
    We are running DS 4 SP2 on Linux and have generated our job script from
    the console. We need to be able to invoke a DS job from scheduler
    (autosys) running on AIX and wait for the DS job to complete so the
    return status is passed back to autosys.
    We are planning to replace informatica with DS, informatica has a utility
    pmcmd which allows remote invocation and will also wait for the job to
    complete. Is there a similar utility in DS?
    Alternately, if we installed DS on the remote AIX server, would it be
    able to remotely start/wait for the job on the Linux server?
    Thanks,

    you can export the job execution command for a job from management console and use that to run the job from auto sys, the script will start job aluncher which has a option -w (by default it waits for job to complete) which tell whether the launcher process waits for job to complete or starts the job and exit

  • Waiting for another script to finish...

    I can no more start or stop FMS3 server, it says :
    Waiting for another script to finish...
    According to the start script, i check
    /home/fms/tmp/script.lck and i have this file as empty, what should
    i do then ?
    Do you all have this file ? /home/fms/tmp/script.lck ?
    Jerome

    My reply is late i just read your problem after having the same, it locked up my whole Ubuntu system.
    Its easy to solve just delete the lock folder you see. Server should restart and work fine.

  • 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");

  • Officejet pro 8600 waiting for job to complete on Mac

    Hi
    I have the problem where after printing the I get the message "waiting for job to complete" which never goes away by itself. I can manually delete the item and then continue to print repeating the process every time I need to pringt.
    I have read the forums and found similar issues but not exactly the same and the recommendation for that was to reset the print system and resinstall. I did that but the problem persists.
    Printer: Officejet pro 8600 Plus
    OS: OSX 10.9.3
    Connection: Wireless and  USB (same issue with both)
    When I initially installed the printer it worked fine. When I upgraded to 10.9 it worked fine but the problem arose soon after.
    Thanks
    This question was solved.
    View Solution.

    Welcome to the forums MedlandLime,
    I understand you are seeing a message saying "waiting for job to complete" after you print and the message will not dissipate. I saw that you have reset the print system and reinstalled and the message continues. I have some more ideas that might help.
    First of all, test the printer hardware itself and make a couple of copies. If the copies work fine, the printer is okay!
    Next, try updating the printers Firmware through the front panel: Getting the Latest Firmware and Product Updates
    If the issue still persists, follow these steps in order:
    Mac OS X: How to reset the printing system
    Repair disk permissions
    Restart the computer
    Re-add the printer and ensure it's the HP driver and not the AirPrint driver: HP Officejet Pro 8600 series Full Feature Software and Driver- OS X 10.9 Mavericks
    Please let me know the results!
    Have a great Monday
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • All off a sudden I get waiting for job status notification on a package that has worked for years

    Does anyone else have this problem, the package in question is Adobe CS 5.5, this package as worked for years all of a sudden the OSD, gives
    waiting for job status notification and hangs forever on the installation of Adobe CS 5.5
    If I run the batch file manually that I am using in the SCCM package for Adobe CS 5.5
    it works perfectly, but when part of an OSD I now get waiting for job status notification.
    Any advice would be great.

    Hi,
    I recommend you check the following log files on the client.
    AppEnforce.log
    It records details about enforcement actions (install and uninstall) taken for applications on the client.
    execmgr.log
    It records
    details about packages and task sequences that run.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Package deployment keeps getting stuck with message 'Waiting for another program'

    Hi, I just started working on SCCM.  We have an Orchestrator runbook which creates a collection and then creates an advertisement for packages and task sequences.  I was able to get a task sequence and a package successfully execute.  When
    creating the advertisement, I set it to RERUN_ALWAYS.  However, the next time I ran our runbook which creates the collection andadvertisement (I manually deleted the previous one), it does create them but the deployment is stuck to In Progres with the
    Description of 'Waiting for another program'.  This just happens for packages before and not for task sequences the other day but now, it's the same issue whether I use a package or a task sequence.   
    I see this in execmgr.log:
    <![LOG[Package UAT0007D, program Test is ready but can not be started because package , program  is currently running.]LOG]!><time="17:07:20.993+480" date="02-06-2015" component="execmgr" context=""
    type="1" thread="6804" file="executionrequest.cpp:9083">
    <![LOG[Raising event:
    [SMS_CodePage(437), SMS_LocaleID(1033)]
    instance of SoftDistProgramWaitingForAnotherProgram
    AdvertisementId = "UAT2011A";
    BlockingPackageID = "";
    BlockingProgramName = "";
    ClientID = "GUID:2FE27567-3215-4015-BE09-0E65F09767C8";
    DateTime = "20150207010721.004000+000";
    MachineName = "ACAA-UAT-SCCM";
    PackageName = "UAT0007D";
    ProcessID = 6316;
    ProgramName = "Test";
    SiteCode = "UAT";
    ThreadID = 6804;
    ]LOG]!><time="17:07:21.010+480" date="02-06-2015" component="execmgr" context="" type="1" thread="6804" file="event.cpp:729">
    <![LOG[Successfully raised SoftDistProgramWaitingForAnotherProgram event for program Test.]LOG]!><time="17:07:21.021+480" date="02-06-2015" component="execmgr" context="" type="1" thread="6804"
    file="executionrequest.cpp:9128">

    yes check the exemgr.log file and also see is that package has dependency for another package? and if yes then that package is already available non DP?
    Sharad Singh | My blogs: SharadTech | Twitter:
    @SinghSharaad | | Please remember to click “Mark as Answer” on the post that helps you.This can be beneficial to other community members reading the thread.

  • [Solved] systemd does not wait for the unit to finish

    My problem is described in the title. I have made a test by enabling the following unit:
    [Unit]
    Description=/etc/rc.local Compatibility
    [Service]
    Type=forking
    ExecStart=/bin/sleep 1000
    TimeoutSec=0
    RemainAfterExit=yes
    After=network.target
    [Install]
    WantedBy=multi-user.target
    The unit is well started (a process sleep 1000 exists). But with a type=forking, systemd is supposed to hang in this case. Instead, the graphical.target is launched, systemctl list-units mention it as dead, but the display manager is started before the sleep 1000 completes. Ho can I force systemd to wait?
    Last edited by olive (2015-03-16 16:49:34)

    olive, now you're making even less sense. I didn't say the sleep example was stupid and I didn't question your reasons for doing/wanting this.
    I suggested you add "Before=display-manager.service" and you respond "I added Before=graphical.target and it didn't change anything."
    I also tried to explain why systemd has no reason to delay the display-manager.service. You could have asked for further clarification, as berbae has now done. Let's try a longer explanation.
    Service startup
    Services can be started in different ways, as configured with Type=. This determines when a service is considered "started" (or when the service's start-up is considered finished). When a service reaches this state (some time after being started), units that are supposed to start After= this service will be started (and no sooner).
    With simple systemd has no further information about the start-up process. It launches whatever you specify in ExecStart and this is the main process that continues to run till the service stops. systemd assumes this type of service is started immediately. All the other types have some way for the process to indicate to systemd (either directly or indirectly) when it has finished starting.
    Actually oneshot is also a bit special and that is where RemainAfterExit comes in. For oneshot, systemd waits for the process to exit before it starts any follow-up units (and with multiple ExecStarts I assume it waits for all of them). So that automatically leads to the scheme in berbae's last post. However, with RemainAfterExit, the unit remains active even though the process has exited, so this makes it look more like "normal" service with
    begin of unit/startup ---- end of startup ------ end of unit
    This is the relevant behavior for this thread. First sleep starts, then after 1000 seconds, start-up finishes and follow-up units will be started. Then either the unit dies, or (with RemainAfterExit) it stays "active".
    The man page describes how "end of startup" is determined for each Type.
    Targets
    Targets are meant to group units together, to provide synchronization points (and replace runlevels). When you start a target, all its units will be started (in parallel if possible). The man page says:
    Unless DefaultDependencies= is set to false, target units will
           implicitly complement all configured dependencies of type Wants=,
           Requires=, RequiresOverridable= with dependencies of type After= if the
           units in question also have DefaultDependencies=true.
    This means that (by default) when a target is requested, all it units are started first. Only after all units have finished starting, the target itself will be started (and since the target doesn't do anything by itself, this startup is basically instantaneous). Without this dependency, the order between the target and its units is unspecified, so in theory the target could finish starting immediately while its units are still being started.
    Back to olive
    graphical.target has these DefaultDependencies, so it is not started until all its units (like display-manager.service) and other After= dependencies (like multi-user.target) have finished starting. Your sleep service has to be started before multi-user.target starts (again due to default target dependencies). So first display-manager and the sleep service are started and after 1000 seconds, the sleep service finishes starting and then (assuming all other dependencies were quicker) multi-user.target is started and graphical.target as well (assuming display-manager didn't need 1000 seconds).
    If you want display-manager.service after the sleep service, add a Before/After line to specify that (this was your original goal and my suggestion).
    olive wrote wrote:However, units that are parts of the graphical target are still launched before the graphical target become active. I am still unable to completely delay the starts of the graphical target before a specific unit completes.
    It should be clear now how this works. "units that are part of the graphical target" can only mean "units that are wanted/required by the graphical target" but that is basically all the units that are started when you boot your system, because multi-user.target is a part of graphical.target. And your sleep service is a part of multi-user.target, so in fact you're saying you want to delay starting the sleep service until the sleep service completes
    What you probably intended was to delay all units that are a part of graphical.target but not of multi-user.target until after the sleep service. I can't think of an easy (or even good) way to do this and this post is already too long, so I'll table that for now.

  • Asynchrono​us Call - collect values without waiting for sub VI to finish executing

    Hi All, I'm relatively new to LabVIEW and for the first time I'm attempting to make use of Asynchronous calls in a program.
    What I would like to accomplish, generally, is this: At the beginning of the main vi, begin running a sub-vi in the background. This sub-vi is collecting streaming data from an instrument with a refresh rate of 50Hz. At various points in the main vi I would like to call the instantaneous value of that streaming data from the sub vi, passing it back into the main vi, while allowing the sub-vi (the streaming data collection) to continue running. The reason for this, is that I need to collect the data from this instrument many times wihtin a loop, and the connection initialization to the streamin data instrument is both slow and faulty, and takes too long if I have to initialize the connection, collect the data, close the connection, each time I wish to collect the data. I would prefer to initialize the connection once at the beginning, have a stream of continuous data being collected in the background, and then at certain points within the main vi loop, query that streaming data for its instantaneous value, but allow the streaming data sub vi to continue running.
    I recognize that a method to allow the streaming data collection sub vi to run in the background is to use the Asynchronous call method - however, to collect the data I need to use an asynchronous wait, which will only collect the data if the streaming data sub vi finishes executing. How can I collect the data at a particular instant while still allowing the subvi to keep running (thereby minimizing the number of times the connection to the instrument needs to initialized)?
    Any suggestions or alternative methods would be great!
    Thanks
    Jason

    This is typically solved in a different way than what you envision. Have your parallel deamon post its current values to a buffer. This could be a global variable (gasp!!) or an intelligent global variable (a VI with loop that executes always once and has an unitialized shift register that can either be initized or read based on a control input). You can add extra code to the read and write selection such as scaling etc to turn the intelligent global into an action engine that does extra things on its different methods.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions
    Attachments:
    Intelligent Global.vi ‏19 KB

  • 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

  • How long is the wait for uptodate program?

    I bought a macbook pro on 23rd July which is after Lion release, and it still shipped with Snow Leopard. Applied to the "uptodate" program on 24th, and it is now 1st of august! Nine days and waiting, and no response at all. What am I suppose to do?

    I'm just wondering if there's a way to find out how long a wait to expect between each new episode of a show you've bought a season pass to?
    Sorry but no, there isn't. The iTunes Store normally posts episodes as soon as they get the episodes from the producers (barring a technical problem with the video that would require the iTunes Store to request a new copy).
    Since the show is screened weekly in my country, I can't see the reason for the 2 week+ wait. Any ideas?
    Probably delays or problems at the production house.
    If not, I can't seem to find a questions/complaints email address for iTunes Australia, can you point me in the right direction?
    http://www.apple.com/au/support/itunes/contact.html
    Though there's probably nothing they can tell you, but it won't hurt to contact them as ask what's going on.

  • I am getting a "Waiting for Background Program to Close" message when shutting down since the installation of CC 2014

    Hi there
    I know Microsoft support says this message can be neglected. Anyway, I was wondering if anybody has a solution.
    Previous Adobe CC versions did not show this problem. As soon as I end the Adobe CC process in the task manager manually, I can shut down the PC without getting this message.
    Soft- and hardware used:
    Windows 7 64bit, service pack 1 installed
    Intel i7-2600k
    GPU Asus GTX 970 STRIX
    Thanks for any ideas.
    Cheers
    Juerg

    That's most likely simply sloppy programming on one of the web extensions not correctly responding to system shutdown messages and closing their ports... Annoying, but not critical. If you don't use it, you can always turn off TypeKit and the sync features.
    Mylenium

Maybe you are looking for

  • I did a software update on my IPhone 4S and now it's frozen at the apple symbol. hard reseting doesn't help??

    I did a software update on my IPhone 4S and now it's frozen at the apple symbol. hard reseting doesn't help?? HELP!!!!!!!

  • Monitoring RAID with Solaris 10 x86 and Dell PowerEdge 2650 PERC 3/Di

    Hello, I have a PowerEdge 2650 with the PERC 3/Di RAID controller. The OS installed is Solaris 10 8/07 U4. Currently RAID is configured through the BIOS and it works fine, but I have no way to monitor the status of the drives. Is there a command to s

  • CC line items

    hi I have a created contract PO but I can not see any committed line items on the cost center (KSB2) or on the project level (CJI5). can anyone help me? thanks

  • Pages mess up with email signature

    Hello, I've a problem with pages. When I send an E-mail with mail app, the recipient get the email with the correct signature on it. When i send a file from Pages, the signature is "gone" and it's added in a "ATT00007.txt" file attached to the email.

  • Mac App Store troubles

    So earlier today I bought iMovie 11 for my Macbook and installed it and it had a problem where the video window was always black no matter what type of video or photo you tried to play. So I decided to clean install of Mac OS X. I finished the instal