I am inserting records from an array to a system,since if the count of array records goes beyond 999 system will break , so i want to make the compiler sleep for 2 seconds once 998 records are processed , in Java ..how can I do the same? I am working in Gosu which is a technology similiar to Java 8 .Thanks in Advance
Asked
Active
Viewed 79 times
-1
-
3Sidebar comment: you're confusing the [Compiler](https://en.wikipedia.org/wiki/Compiler) with something else. – robotlos May 03 '16 at 00:02
-
1You can't make the compiler sleep at all. You can make the *current thread* sleep. – user207421 May 03 '16 at 00:07
-
Thanks EJP for correcting me – Gaurav Bhatia May 03 '16 at 16:25
1 Answers
2
You may want to use Thread.sleep()
.
try {
Thread.sleep(2000); // 2 seconds
} catch (InterruptedException e) {
// do something if necessary
}

MikeCAT
- 73,922
- 11
- 45
- 70
-
Do we really need an answer when there are thousands of duplicates to this question? – Hovercraft Full Of Eels May 03 '16 at 00:22
-
thanks all, but my question was linke dto gosu technology ,Anyways got the fix from,it was breaking the collection to sub collections and passing ,no need for thread to sleep .Thanks All – Gaurav Bhatia May 03 '16 at 16:24