Continue while loop after getting exception

I have a java class that instantiates another java class extended from thread, i.e.
public class ClassA {
public static void main(string() args) {
start();
public void start() {
ClassB thread = new ClassB();
thread.start();
public ClassB extends Thread {
public void run() {
ArrayList list = null;
list = getList();
Iterator i = list.iterator();
while (i.hasNext()) {
BigDecimal sequence = (BigDecimal) i.next();
ClassC classC = new ClassC();
try {
classC.doProcessList(sequence);
} catch (Exception e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
when classC.doProcessList(sequence); throw exception the whole execution
stops. I want to continue with the next sequence number in the list. How do I do that. throwing try - catch around doProcessList does not help.
Any suggestions? TIA

Using code tags enhances readability.
I'm assuming this is not really the code you are working with, you have generated sample code very quickly. This code won't even compile. Among the errors - you have an extra catch block which shouldn't be there.
But you could verify the size of the list just to be sure.
System.out.println( list.size() );I assume you are trying to do something like this ?
public class ClassA {
     public static void main(String[] args) {
          new ClassA().start();
     public void start() {
          ClassB thread = new ClassB();
          thread.start();
public class ClassB extends Thread {
     public void run() {
          int i = 0;
          while( i < 5 ) {
               try {
                    System.out.println("" + i++ );
                    throw new Exception("Stop");
               } catch( Exception e ) {
                    System.out.println("Exception caught");
}0
Exception caught
1
Exception caught
2
Exception caught
3
Exception caught
4
Exception caught

Similar Messages

  • How to continue the loop after getting the exception NO_DATA_FOUND

    I am inserting 2000 employees attendance data into table through procedure by validating the shifts assigned some times if employee doesn't have shift it raising NO_DATA_FOUND exception, so now I am inserting the details of the employee into one table as a log.
    my question is if 2000 transactions are inserting if exception raised at 1000 record as "NO_DATA_FOUND" is it remaining records will insert into the table? or it will exit from the procedure and stops remaining 1000 transactions?, please advice if any other way to continue the remaining transactions
    oracle version: 11 G R2, OS: Windows 2008 R2

    Do your select statement in a seperate begin...end block, you can cath the excption in the block and do your logging there.
    Something like this
    --just an example from scott/tiger
    Declare
    CNT number := 7851 ;
    vname varchar2(25);
    ins_flag boolean ;
    BEGIN
    while cnt  <= 7935 and cnt >=7850
    LOOP
    Begin
    select ename into vname from emp where empno=cnt ;
    ins_flag := true;
    exception
      when no_data_found then
    -- dbms_output.put_line('no data');
    ins_flag := false;
    end;
      if ins_flag then
      --do insert here
      dbms_output.put_line('do your insert here');
    else
      dbms_output.put_line('no insert');
    end if;
      cnt := cnt+1 ;
    END LOOP;
    end;

  • How to stop a while loop after certain time using Elapsed time vi

    how to stop a while loop after certain time using Elapsed time vi.

    Hi Frankie,
    Just place the Elapsed Time VI inside the WHILE loop, and wire the 'Time Has Elapsed' output to the conditional terminal in the lower right corner (which should be set to 'stop if true' by default).
    In the future, please post your LabVIEW questions to the LabVIEW Forum.  You have a much better chance of getting your questions answered sooner, and those answers can then help others who are searching the LabVIEW forums.  Thanks!
    Justin M
    National Instruments

  • Stopping while loop after last element of 2d array is passed through

    I posted something similar to this before, but what I got didn't work.  So this time I'll try to be more clear with what I am trying to do.  What I have done is combine two 1d arrays into a 2d array, and am using it to run an experiment.  I split the 2d array into a 1d array by column, and am trying to get the while loop that the array is in to stop after  the last element of the array is indexed.  I need to use a while loop because the array is constantly updating because the number of elements can be changed while the program is running.  What I am having trouble with is getting the while loop to stop after the last element has run, because the last element is subject to change.  Any ideas?
    Thanks 

    I am trying to run a measurement using labview to control different instruments.  The program is suppossed tp work in that it runs a measurement for each current setpoint inputed, for 1 magnetic field setpoint.  So for example, if the magnetic field setpoint is 8000 gauss, and the two current setpoints are .00001 amp, and .0001 amp, it will run the meauserement twice for the 2 current setpoints for each magnetic field setpoint.  What I am trying to do is that sometimes, I might have to edit the magnetic field setpoints while the program is running.  I am having trouble with refreshing the magnetic field setpoints, which allows the user to input a new magnetic field setpoint while it is running.

  • Writing a file for prescribed amount of time in a while loop after the triggering condition is met

    Hello Guys,
    I am trying to program an application in which if the trigger condition is met it should start to write the file.
    I was able to do that, but if I want it to be written for certain amount of time, and once the trigger condition is met, it should continue to write the files for prescribed amount of time. I was not able to do this. The file name should also be updated accordingly.
    I tried to with some options by keeping the creation of the file outside of the loop, if I do that then if the trigger condition is not met it will stop writing and I dont want that, as once the trigger condition is met it should be true thereafter.
    So I cant keep any thing outside the while loop, bcaz then it checks the condition of the shift register for the trigger and I have it as a false constant.
    I am attaching my application which is kind of mess and I have written in the application where I am having problems. For every iteration of while loop it makes a new file, and i dont want that, I want to write specific amount of time data to the each file.
    Please take a look at my code and help me in solving the problem. Any insights and examples on how to do this thing will be a relief to me.
    Thanks in advance.
    Regards,
    Nitin
    Attachments:
    PXI_4462_Sync_and_Stream_trigger.zip ‏192 KB

    what i am saying is to keep track of how much data you have written and whenever you need to make a new file you make 1.
    here is a vi that i just made that should show you. let me know if you need any help understanding it.
    Attachments:
    new file exemple.vi.zip ‏21 KB

  • Pause and restart while loop after defined time

    Hello,
    What I need is to find a way to run a while loop that is acquiring and analysing a movie, to pause this while loop for a time I specify, and re-run it after that time has passed.
    I'm attaching a picture of the relevant parts of my VI. In the case structure of the "true" or "false", the program is checking, online, if the eye (my camera is focusing on the eye) is open above some threshold and for a certain duration of time. When "condition to start" is met, two things happen: one, the case structure changes to "false" and waits for some time; second, the loop of my state machine is triggered. Problem is, because I'm not really pausing my while loop (it's still running even when it's the "false" case), my state machine runs really slowly - for example, I have a part of video acquisition in my state machine, and saving the frames to avi takes forever. 
    Does anyone have any idea of how I could stop the while loop for x time?
    Thanks in advance!
    Attachments:
    help_pauseWhileLoop.png ‏112 KB

    Hi,
    I'm attaching (hopefully) better pics, if you still can't see let me know and I'll attach the code. About the frame saving and acquistion, I'm already doing that in a separate loop - you can't see my entire code in the pics, but what I have is a state machine that works as a producer loop and then a consumer loop, where video acquisition is happening. Now I'm working on a third loop (the one in the picture), that starts before the others and where I don't even want to save the movies - I just want it to check, online, if the condition is met (e g, the eye is open for a specified time) and if so, start the state machine and stop running, until the state machine has finished running. Then do the same, after waiting a specified time. I know that the problem is that the while loop keeps running after triggering the state machine, because if I remove that part and trigger it manually, the VI runs just fine and really fast. So how can I run, stop and restart the while loop?
    Attachments:
    help_pauseWhileLoop1.png ‏56 KB
    help_pauseWhileLoop2.png ‏32 KB

  • I noticed that any other code in my while loop only gets called at the 1st time through the loop and when a event is executed.

    HI there!
    I have a while loop, in which i am reading from/writing  to a compact rio. Furthermore, i added a event structure, its the 1st time i'm using it so i'm a bit lost at times.
    I have the event structure set up for all my button i want to trigger an event. However, i have some other code which i would also like to be executed, evebn though no event has been executed.
    I noticed that the other stuff in the loop only gets executed the 1st time through the loop and when an event is triggered.
    My question therefore is, how do i get the other stuff to execute as well?
    Please advise.
    Thanks.
    Regards,

    Put the other code in the timeout event case.  Wire some positive value to the timeout hourglass input.  That code will execute everytime a timeout occurs.  For instance, if you wire 100 into the timeout, the code in that case will execute every 100 mSec.
    - tbob
    Inventor of the WORM Global

  • How to continue a loop after roll back callee a Transaction in SOA

    Hi All,
    I Have main bpel process which calls a external web service which returns  set of records,
    iiterate through the set, i need to store the each record in AQ Topic.
    and ack each and every record after storing them in AQTopic. if the Ack fails i should roll back the previously inserted record from AQ.
    I Divided the XA transaction into two parts by using "checkpoint();" .
    Based on the ack status i called throw activity with Rollback transaction, i handled that using catch all in same scope.but after that process is terminating not iterating through the loop.
    i used XA Datasource.
    please suggest me.
    Thanks Rajashekar.

    Hi PuneetRekhade,
    Thanks for your suggestion.
    After receving the ack=sucess, before storing the Record in the AQ if system crashes Data would no longer exist in Either AQ or external web service Data base .
    the Record shouldn't be lost at any cost.
    in my case, if the system crashes before sending the data to AQ, nothing happens because i wouldn't send the ack to the External web service.
    Thanks
    Raj.

  • To Get Dynamic filenames while using sync get FTP Adapter?

    Instead of looping and getting filenames after file listing...
    i am thinking to use flow N.instead of while loop after filelisting..
    i am able to find, different file names in the assign activity, before the invoke activity which is assigned to Sync get adapter.
    but the sync get adapter is getting same file names in all the parallel flows.
    i can see it can successfully transfer one file, but fails with rest of those.
    is there any possibility, to pass file names dynamically to the sync get adapter..

    I want to conform you again, i want to use FLOW N instead of while..
    In whileloop the logic works fine, but when it comes to FLOW N , its failing
    as requested, code is fallows
    <assign name="Assign_InputDetails"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <copy>
    <from expression="bpws:getVariableData('Invoke_FileListing_OutputVariable','filelist','/ns2:filelist/ns2:file[position()=$i]/ns2:filename')"/>
    <to variable="Filename"/>
    </copy>
    <copy>
    <from expression="bpws:getVariableData('Invoke_FileListing_OutputVariable','filelist','/ns2:filelist/ns2:file[position()=$i]/ns2:directory')"/>
    <to variable="InputDir"/>
    </copy>
    </assign>
    <invoke name="Invoke_GetInovice"
    inputVariable="Invoke_GetInovice_InputVariable"
    outputVariable="Invoke_GetInovice_OutputVariable"
    partnerLink="GetSourceFiles"
    portType="ns4:SynchRead_Inovice_ptt"
    operation="SynchRead_Inovice"
    bpelx:invokeAsDetail="no">
    <bpelx:inputProperty name="jca.ftp.FileName"
    variable="Filename"/>
    <bpelx:inputProperty name="jca.ftp.Directory"
    variable="InputDir"/>
    </invoke>
    where i in [position()=$i] is index variable declared in FLOW N

  • Starting new while loop while old one still running

    Hi!
    I am attempting to write video images to AVI files. I want to give the user the option to decide when they want to begin to capture the images. I place the "start recording" button in one loop and the image acquisition and AVI Write subVIs in another loop. LabVIEW won't allow me to continue on with the image acquisition loop until I finish with the "start recording" loop. Any ideas how to fix this (to allow the image acquisition to start and continue having LabVIEW check for a button press on "start recording")?
    Attachments:
    Capture_and_Save_as_AVI.vi ‏177 KB

    Thanks. I suspected as much. In any event, I can't seem to find a good configuration of while loops and case structures which will produce the desired results. I want to start acquiring images and allow the user to choose to start recording at any time he desires. This issue is further complicated by the fact that the status of the "Start recording" must be checked at all times, but only initialized once, while the AVI Write Frame depends on that first initialization step but must be looped continuously aferwards in order to 'keep up' with the images being acquired. In the newly attached example, I placed the case structure inside the image acquisition while loop and the avi write frame inside a while loop inside of that case structure. unfortunately,
    labview decides to stay inside the avi write frame while loop after entering, instead of returning to the image acquisition while loop. i can't place the avi write frame inside the general image acquisition while loop because then labview will think i want to initialize the avi write frame right away and will return an error when avi write frame isn't provided with an avi refnum. Ideas?
    Attachments:
    Capture_and_Save_as_AVI.vi ‏174 KB

  • Editing While Loop Conditions hangs JDeveloper 10.1.3

    Hi Guys,
    Having a strange problem when I tried to edit the condition in a while loop after it was created and set first time. The IDE just hanged when I tried to open the expression builder and after a while, nothing happened, the expression builder didn't show up.
    I went and deleted the condition by editing the source, basically made condition from:
    <while name="While_1"
    condition="bpws:getVariableData('inputVariable','payload','/client:WhileLoopTesterProcessRequest/client:input')&lt;10">
    to
    <while name="While_1"
    condition="">
    Switched back to graphics mode, the expression builder opens up normally.
    I understand that we are evaluation a Developers Preview, so just wanted to bring this to the notice of the developers.
    Any solutions before the Production release?
    Regards,
    - Soumen.

    Hi Willian,
    Did you set up your "Model" Project to use the JDK 1.4 and rebuild the application ?
    See " [Deploying to Application Servers That Support JDK 1.4|http://tinyurl.com/lfc6kc] "
    Regards,
    Didier.

  • I am using the "Menu Selection With Events.vi" example alongside other while loops, When I select exit from the new menu it stops the other while loops but not the menu/event while loop

    The event driven menu example works fine and I've integrated it into my application. I have built in simple local vars to link menu selections to existing GUI buttons. The problem is that I cannot get the File-Exit menu option to switch off/terminate the application. The [1] "Stop": Value Change panel of the event structure simply switches off the other while loops but leaves the event while loop running. Add a while loop to the axample using a local var from the event while loop to terminate 2nd while loop to get the effect.
    Help appreciated, Chris

    Attached you will find a modified version of your VI.
    I documented what I did on the block diagram.You were right on you just needed to add a variable with a true wired to it.
    Have fun with it.
    Joe
    Joe.
    "NOTHING IS EVER EASY"
    Attachments:
    Menu_Selection_with_Events_%26_while_loop[1].vi ‏76 KB

  • Foreach loop, containers and transaction settings and continuing a loop even if a task fails

    I have a foreach loop and a container inside that.  Inside the container are a bunch of tasks.  When one of these tasks fail, I want it to fail the parent container, but not the loop or the package.  
    The package will be run from a sql agent job.  Right now, the package works, but when a task fails inside the container, the sql agent job stops with failure.  I want it to continue unless one of the tasks OUTSIDE of the loop or container fail.
    Am I correct to say that since the foreach loop is the parent of the container, and as long as the foreach loop doesnt fail, the package should continue?

    Hi Shiftbit,
    Yes, the failure of the Script Task will fail the Sequence Container, the Foreach Loop Container as well as the package even though you have set the FailParentOnFailure and the FailPackageOnFailure properties to False. That’s because the package implicitly
    uses Event Handlers to control the failure propagation even though we didn’t add any Event Handlers explicitly. So, if you don’t want the failure of the Script Task to affect its containers and the entire package, you should add an empty OnError Event Handler
    for the Script Task, and then set the value of the System Variable Propagate of the Event Handlers to False.
    If you don’t want the other tasks in the Sequence Container fail the Loop container as well, you don’t need to repeat the operations on each task, instead, you only need to do the same on the Sequence Container.
    References:
    http://agilebi.com/jwelch/2008/06/29/continuing-a-loop-after-an-error/#comment-57484
    http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/08/09/ssis-logging-and-event-propagation.aspx
    Regards,
    Mike Yin
    TechNet Community Support

  • While loop termination...

    So I have this long sequence of frames and I have an while loop which runs outside of the sequence. I want to to terminate the while loop after the last frame of the sequence  has completed. I tried to wire a logic true constant from the last frame to the  while loop but it does not  work because the while loop seems to terminate prematurelly.  Could someone sugguest  a way of dealing with it? I can' figure out a solution for some reason.

    Then the answer is, as with the other case, data dependency. If you wire a value out of your sequence frame into the while loop you've established a data dependency for the while loop since the while loop needs to know what the value of that wire is before it can execute, and the value is not set until the sequence frame ends.
    Since your while loop houses an event structure, generate an event at the end of your sequence frame to stop this parallel loop. A crude solution: Wire a True value to the "Value (Signaling)" property of the "Stop" control, and change the event case from "Mouse Up" to "Value Change". You should make sure to initialize the "Stop" button to False at the start of your program, and to change the mechanical action to "Switch When Released":
    Attachments:
    Example_VI_BD6.png ‏6 KB

  • My Mac G4 came unplugged while running and now when I start it up all I get is a continuous reboot loop.

    While sliding my Mac G4 tower out from under the desk it came unplugged. It was running at the time. After plugging it back in all I get is a continuous reboot loop. I have tried the Shift and the Command Option P R boots to no avail. What am I missing here? I have had no problems in the past with this system. I am running Panther.

    I have tried the Shift and the Command Option P R boots to no avail.
    Are you using an Apple keyboard or something else. It is rather common for non-Apple boards, especially those pulled from a PC, to not respond to the traditional Apple startup key command combos.
    Take the computer off wall power again then press and hold the power button for about 20 seconds. Then restore power and try a normal start. That worked for me when I had a similar failure to start with my G4 MDD.
    If you have never replaced the internal backup battery ("PRAM" battery) it is, by, now surely extremely dead and it could not preserve the needed start parameters when power was unexpectedly cut. If you get the computer going, consider installing a new PRAM battery so you won't replay today's issues. tomorrow. The batteries are cheap and replacing one is a three-minute at-home job:
    NewerTech 3.6v Lithium 1/2 AA PRAM Computer Clock Battery

Maybe you are looking for

  • Error while refreshing a report using local csv file

    Hi, I'm using BI 4.1 SP02. While using Rich client, I've created a report with some merged queries, while one of the queries is a local CSV file - saved on AD in some server, and not on the repository inside BO. While trying to refresh the report wit

  • PDF Viewer component that works in NetBeans VWP

    Hi All, I am looking for a PDF Viewer Component that will work with NetBeans VWP. Ideally, this would be something that I could load into the Pallette and drop on a web form for use, then dynamically call up a document for display within the control.

  • E-coupon? Does it work?!!

    I did receive my e-coupon in few weeks from sending it in. I recently made use of it and applied it to a purchase of some accessories. The coupon was applied on checkout, subtracted from the total amount. But, Apple still deducted full purchase price

  • Music has grey dotted circles?

    Hey, So I was going to put a playlist on my Iphone 4, I used Autofill,But the music had grey dotted circles and  I tried autofilling again but it says i already have the music on my phone, but they're not coming up, i also tried to delete the music b

  • Site to SIte VPN through a NAT device

    I, i am having some trouble running a site to site vpn between two 3725 routers running c3725-advsecurityk9-mz124-15T1 which i hope i can get some help with, i am probably missing something here. The VPN ran fine when both VPN routers were connected