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

 
(사용자 3명의 중간 판 14개는 보이지 않습니다)
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>
 
==Go==
[[분류: Go]]
{{참고|Go sleep()}}
<syntaxhighlight lang='go' run>
package main
 
import (
"time"
)
 
func main() {
time.Sleep(3 * time.Second) // 3 seconds
}
</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번째 줄: 70번째 줄:
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(500000);
usleep(3000000);
// sleep for 500000 milliseconds(0.5 seconds)
# sleep for 3 seconds (3000000 microseconds)
</source>
</syntaxhighlight>


==Python==
==Python==
[[분류:Python]]
[[분류:Python]]
<source lang='python'>
{{참고|파이썬 sleep()}}
<syntaxhighlight lang='python'>
import time
import time
time.sleep(3)
time.sleep(3)
96번째 줄: 112번째 줄:
time.sleep(1.5)
time.sleep(1.5)
# sleep for 1.5 seconds
# sleep for 1.5 seconds
</source>
</syntaxhighlight>
 
==R==
[[분류:R]]
{{참고|R sleep()}}
<syntaxhighlight lang='r'>
Sys.sleep(3)
# sleep for 3 seconds
</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]]
* [[수행시간 측정]]

2023년 4월 25일 (화) 01:01 기준 최신판

  다른 뜻에 대해서는 리눅스 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 Go[ | ]

package main

import (
	"time"
)

func main() {
	time.Sleep(3 * time.Second) // 3 seconds
}

5 Java[ | ]

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

6 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);

7 Objective-C[ | ]

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

8 Perl[ | ]

sleep 3;
# sleep for 3 seconds

9 PHP[ | ]

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

10 Python[ | ]

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

11 R[ | ]

Sys.sleep(3)
# sleep for 3 seconds

12 Ruby[ | ]

sleep(3)
# sleep for 3 seconds

13 UnityScript[ | ]

yield WaitForSeconds (3);

14 같이 보기[ | ]

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