15 Handling Processing Errors. This chapter describes how to configure the Oracle GoldenGate processes to handle errors. Oracle GoldenGate reports processing errors in several ways by means of its monitoring and reporting tools. For more information about these tools, see Chapter 18, 'Monitoring Oracle GoldenGate Processing.' An exception occurs when a package is temporarily delayed while in transit. Exception codes can also be triggered by other situations, some of. If you think you qualify for a refund, reach out to FedEx to start the process.
Active27 days ago
I am trying to do something in Java and I need something to wait / delay for an amount of seconds in a while loop.
I want to build a step sequencer and I'm new to Java. Any suggestions?
lospejos1,60922 gold badges1414 silver badges2626 bronze badges
ardbardb1,54833 gold badges1010 silver badges1515 bronze badges
8 Answers
If you want to pause then use
java.util.concurrent.TimeUnit
:To sleep for one second or
To sleep for a minute.
As this is a loop, this presents an inherent problem - drift. Every time you run code and then sleep you will be drifting a little bit from running, say, every second. If this is an issue then don't use
sleep
.Further,
sleep
isn't very flexible when it comes to control.For running a task every second or at a one second delay I would strongly recommend a
ScheduledExecutorService
and either scheduleAtFixedRate
or scheduleWithFixedDelay
.For example, to run the method
myTask
every second (Java 8):And in Java 7:
Matthew Moisen5,4871717 gold badges6969 silver badges141141 bronze badges
Boris the SpiderBoris the Spider47.9k44 gold badges8484 silver badges126126 bronze badges
Use
Thread.sleep(1000)
;1000
is the number of milliseconds that the program will pause.14.4k1919 gold badges8888 silver badges117117 bronze badges
Ann RaggAnn Ragg2,08422 gold badges1010 silver badges2020 bronze badges
You need to use the
Thread.sleep()
call.More info here: http://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html
RuslanRuslan2,05511 gold badge1313 silver badges2020 bronze badges
Use
Thread.sleep(100);
.The unit of time is millisecondsFor example:
Bachan JosephBachan Joseph
Using
TimeUnit.SECONDS.sleep(1);
or Thread.sleep(1000);
Is acceptable way to do it. In both cases you have to catch InterruptedException
which makes your code Bulky.There is an Open Source java library called MgntUtils (written by me) that provides utility that already deals with InterruptedException
inside. So your code would just include one line:See the javadoc here. You can access library from Maven Central or from Github. The article explaining about the library could be found here
Michael GantmanMichael Gantman2,65311 gold badge77 silver badges2323 bronze badges
I know this is a very old post but this may help someone:You can create a method, so whenever you need to pause you can type
pause(1000)
or any other millisecond value:This is inserted just above the
public static void main(String[] args)
, inside the class. Then, to call on the method, type pause(ms)
but replace ms
with the number of milliseconds to pause. That way, you don't have to insert the entire try-catch statement whenever you want to pause.dominic03dominic03
purav desaipurav desai
use this:
then you can call this method anywhere like:
Axois1,17411 gold badge33 silver badges1515 bronze badges
HecanetHecanet
Not the answer you're looking for? Browse other questions tagged javawaitsleepthread-sleep or ask your own question.
Active27 days ago
I am trying to do something in Java and I need something to wait / delay for an amount of seconds in a while loop.
I want to build a step sequencer and I'm new to Java. Any suggestions?
lospejos1,60922 gold badges1414 silver badges2626 bronze badges
ardbardb1,54833 gold badges1010 silver badges1515 bronze badges
8 Answers
If you want to pause then use
java.util.concurrent.TimeUnit
:To sleep for one second or
To sleep for a minute.
As this is a loop, this presents an inherent problem - drift. Every time you run code and then sleep you will be drifting a little bit from running, say, every second. If this is an issue then don't use
sleep
.Further,
sleep
isn't very flexible when it comes to control.For running a task every second or at a one second delay I would strongly recommend a
ScheduledExecutorService
and either scheduleAtFixedRate
or scheduleWithFixedDelay
.For example, to run the method
myTask
every second (Java 8):And in Java 7:
Matthew Moisen5,4871717 gold badges6969 silver badges141141 bronze badges
Boris the SpiderBoris the Spider47.9k44 gold badges8484 silver badges126126 bronze badges
![Exception, Exception,](/uploads/1/2/5/7/125704477/444258559.png)
Use
Thread.sleep(1000)
;1000
is the number of milliseconds that the program will pause.14.4k1919 gold badges8888 silver badges117117 bronze badges
Ann RaggAnn Ragg2,08422 gold badges1010 silver badges2020 bronze badges
You need to use the
Thread.sleep()
call.More info here: http://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html
RuslanRuslan2,05511 gold badge1313 silver badges2020 bronze badges
Use
Thread.sleep(100);
.The unit of time is millisecondsFor example:
Bachan JosephBachan Joseph
Using
TimeUnit.SECONDS.sleep(1);
or Thread.sleep(1000);
Is acceptable way to do it. In both cases you have to catch InterruptedException
which makes your code Bulky.There is an Open Source java library called MgntUtils (written by me) that provides utility that already deals with InterruptedException
inside. So your code would just include one line:See the javadoc here. You can access library from Maven Central or from Github. The article explaining about the library could be found here
Michael GantmanMichael Gantman2,65311 gold badge77 silver badges2323 bronze badges
I know this is a very old post but this may help someone:You can create a method, so whenever you need to pause you can type
pause(1000)
or any other millisecond value:This is inserted just above the
public static void main(String[] args)
, inside the class. Then, to call on the method, type pause(ms)
but replace ms
with the number of milliseconds to pause. That way, you don't have to insert the entire try-catch statement whenever you want to pause.dominic03dominic03
purav desaipurav desai
use this:
then you can call this method anywhere like:
Axois1,17411 gold badge33 silver badges1515 bronze badges
HecanetHecanet