Sleep: Difference between revisions

1,090 bytes added ,  3 months ago
m
→‎{{header|Wren}}: Changed to Wren S/H
imported>Acediast
(→‎{{header|COBOL}}: added CONTINUE AFTER from COBOL 2023)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(4 intermediate revisions by 3 users not shown)
Line 898:
 
=={{header|COBOL}}==
COBOL 2023 introduced the <code>AFTER</code> phrase of the <code>CONTINUE</code> statement to specify a time period in seconds for which execution will be suspended, which, depending on implementation, could be not an integer.
{{works with|GnuCOBOLCOBOL 2023}}
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Sleep-In-Seconds.
Line 1,103:
})
}</syntaxhighlight>
 
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
print "How many seconds should I sleep? "
sec = number input
print "Sleeping ..."
sleep sec
print "Awake!"
</syntaxhighlight>
 
=={{header|EGL}}==
Line 1,491 ⟶ 1,500:
}
}</syntaxhighlight>
 
===Using Java 8===
<syntaxhighlight lang="java">
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
 
public final class Sleep {
public static void main(String[] args) {
try {
System.out.println("Enter time to sleep in milliseconds:");
Scanner scanner = new Scanner(System.in);
final int delay = scanner.nextInt();
scanner.close();
System.out.println("Sleeping...");
TimeUnit.MILLISECONDS.sleep(delay);
System.out.println("Awake!");
} catch (InputMismatchException | InterruptedException exception) {
exception.printStackTrace(System.err);;
}
}
}
</syntaxhighlight>
{{ out }}
<pre>
Enter time to sleep in milliseconds:
4321
Sleeping...
Awake!
 
</pre>
 
=={{header|JavaScript}}==
Line 2,621 ⟶ 2,664:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">import "timer" for Timer
import "io" for Stdin, Stdout
 
9,476

edits