"함수 sleep()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
5번째 줄: 5번째 줄:
==Bash==
==Bash==
[[분류:Bash]]
[[분류:Bash]]
<source lang="bash">
<syntaxhighlight lang="bash">
sleep 3  
sleep 3  
# Sleep for 3 seconds
# Sleep for 3 seconds
14번째 줄: 14번째 줄:
sleep 3h  
sleep 3h  
# Sleep for 3 hours.
# Sleep for 3 hours.
</source>
</syntaxhighlight>


==CMD==
==CMD==
[[분류:Cmd]]
[[분류:Cmd]]
<source lang='bash'>
<syntaxhighlight lang='bash'>
timeout 3 /NOBREAK > nul
timeout 3 /NOBREAK > nul
REM Sleep for 3 seconds.
REM Sleep for 3 seconds.
</source>
</syntaxhighlight>
<source lang='bash'>
<syntaxhighlight lang='bash'>
ping 2.2.2.2 -n 1 -w 3000 > nul
ping 2.2.2.2 -n 1 -w 3000 > nul
REM Sleep for 3 seconds.
REM Sleep for 3 seconds.
</source>
</syntaxhighlight>


==C#==
==C#==
[[분류:Csharp]]
[[분류:Csharp]]
<source lang='csharp'>
<syntaxhighlight lang='csharp'>
System.Threading.Thread.Sleep(3000);  
System.Threading.Thread.Sleep(3000);  
// Sleep for 3 seconds.
// Sleep for 3 seconds.
35번째 줄: 35번째 줄:
System.Threading.Thread.Sleep(new TimeSpan(0, 3, 0));
System.Threading.Thread.Sleep(new TimeSpan(0, 3, 0));
// Sleep for 3 minutes.
// Sleep for 3 minutes.
</source>
</syntaxhighlight>


==Java==
==Java==
[[분류:Java]]
[[분류:Java]]
{{참고|자바 Thread.sleep()}}
{{참고|자바 Thread.sleep()}}
<source lang='java'>
<syntaxhighlight lang='java'>
Thread.sleep(3000);
Thread.sleep(3000);
// Sleep for 3 seconds.
// Sleep for 3 seconds.
</source>
</syntaxhighlight>


==JavaScript==
==JavaScript==
[[분류:JavaScript]]
[[분류:JavaScript]]
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
function sleep(ms){
function sleep(ms){
   ts1 = new Date().getTime() + ms;
   ts1 = new Date().getTime() + ms;
55번째 줄: 55번째 줄:
sleep(5*1000);
sleep(5*1000);
console.log("done...");
console.log("done...");
</source>
</syntaxhighlight>
<source lang='javascript'>
<syntaxhighlight lang='javascript'>
console.log("wait 5s.");
console.log("wait 5s.");
setTimeout(function() {
setTimeout(function() {
   console.log("done..");
   console.log("done..");
}, 5000);
}, 5000);
</source>
</syntaxhighlight>


==Objective-C==
==Objective-C==
[[분류:Objective-C]]
[[분류:Objective-C]]
<source lang='objc'>
<syntaxhighlight lang='objc'>
[NSThread sleepForTimeInterval:3.0];
[NSThread sleepForTimeInterval:3.0];
// Sleep for 3 seconds.
// Sleep for 3 seconds.
</source>
</syntaxhighlight>


==Perl==
==Perl==
[[분류:Perl]]
[[분류:Perl]]
<source lang='perl'>
<syntaxhighlight lang='perl'>
sleep 3;
sleep 3;
# sleep for 3 seconds
# sleep for 3 seconds
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[분류:PHP]]
[[분류:PHP]]
<source lang='php'>
<syntaxhighlight lang='php'>
sleep(3);
sleep(3);
# sleep for 3 seconds
# sleep for 3 seconds
</source>
</syntaxhighlight>
<source lang='php'>
<syntaxhighlight lang='php'>
usleep(3000000);
usleep(3000000);
# sleep for 3 seconds (3000000 microseconds)
# sleep for 3 seconds (3000000 microseconds)
</source>
</syntaxhighlight>


==Python==
==Python==
[[분류:Python]]
[[분류:Python]]
<source lang='python'>
<syntaxhighlight lang='python'>
import time
import time
time.sleep(3)
time.sleep(3)
96번째 줄: 96번째 줄:
time.sleep(1.5)
time.sleep(1.5)
# sleep for 1.5 seconds
# sleep for 1.5 seconds
</source>
</syntaxhighlight>


==Ruby==
==Ruby==
[[분류:Ruby]]
[[분류:Ruby]]
<source lang='ruby'>
<syntaxhighlight lang='ruby'>
sleep(3)
sleep(3)
# sleep for 3 seconds
# sleep for 3 seconds
</source>
</syntaxhighlight>


==UnityScript==
==UnityScript==
[[분류:UnityScript]]
[[분류:UnityScript]]
<source lang='javascript'>
<syntaxhighlight lang='javascript'>
yield WaitForSeconds (3);
yield WaitForSeconds (3);
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[리눅스 sleep]]
*[[리눅스 sleep]]

2020년 11월 2일 (월) 02:33 판

  다른 뜻에 대해서는 리눅스 sleep 문서를 참조하십시오.
sleep
timeout

1 Bash

sleep 3 
# Sleep for 3 seconds

sleep 3m 
# Sleep for 3 minutes.

sleep 3h 
# Sleep for 3 hours.

2 CMD

timeout 3 /NOBREAK > nul
REM Sleep for 3 seconds.
ping 2.2.2.2 -n 1 -w 3000 > nul
REM Sleep for 3 seconds.

3 C#

System.Threading.Thread.Sleep(3000); 
// Sleep for 3 seconds.

System.Threading.Thread.Sleep(new TimeSpan(0, 3, 0));
// Sleep for 3 minutes.

4 Java

Thread.sleep(3000);
// Sleep for 3 seconds.

5 JavaScript

function sleep(ms){
  ts1 = new Date().getTime() + ms;
  do ts2 = new Date().getTime(); while (ts2<ts1);
}
console.log("wait 5s.");
sleep(5*1000);
console.log("done...");
console.log("wait 5s.");
setTimeout(function() {
  console.log("done..");
}, 5000);

6 Objective-C

[NSThread sleepForTimeInterval:3.0];
// Sleep for 3 seconds.

7 Perl

sleep 3;
# sleep for 3 seconds

8 PHP

sleep(3);
# sleep for 3 seconds
usleep(3000000);
# sleep for 3 seconds (3000000 microseconds)

9 Python

import time
time.sleep(3)
# sleep for 3 seconds
time.sleep(1.5)
# sleep for 1.5 seconds

10 Ruby

sleep(3)
# sleep for 3 seconds

11 UnityScript

yield WaitForSeconds (3);

12 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}