|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| ÀÌÀü Ŭ·¡½º ´ÙÀ½ÀÇ Å¬·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
| °³¿ä: NESTED | ¿°ÅÇü Á¤¼ö | Çʵå | ¸Þ¼µå | »ó¼¼: ¿°ÅÇü Á¤¼ö | Çʵå | ¸Þ¼µå | |||||||||
java.lang.Objectjava.lang.Enum <TimeUnit >
java.util.concurrent.TimeUnit
public enum TimeUnit
TimeUnit´Â ±â°£ÀÌ ÁöÁ¤µÈ ÀÔµµ ´ÜÀ§·Î ³ªÅ¸³À´Ï´Ù. À̰ÍÀº ´ÜÀ§°£ÀÇ º¯È¯À» ½Ç½ÃÇØ, ÀÌ·¯ÇÑ ´ÜÀ§·Î ŸÀÌ¹Ö ¹× Áö¿¬ Á¶ÀÛÀ» ½ÇÇàÇÏ´Â À¯Æ¿¸®Æ¼ ¸Þ¼µå¸¦ Á¦°øÇÕ´Ï´Ù. TimeUnit´Â ½Ã°£ Á¤º¸¸¦ °ü¸®ÇÕ´Ï´Ù¸¸, ´Ù¾çÇÑ ÄÁÅØ½ºÆ® °£¿¡ º°°³¿¡ °ü¸®µÇ´Â ½Ã°£Ç¥ÇöÀ» Á¤¸® ¹× »ç¿ëÇϴµ¥ µµ¿òÀÌ µË´Ï´Ù.
TimeUnit´Â
ÁÖ·Î ½Ã°£ º£À̽ºÀÇ ¸Þ¼µå¿¡
ÁöÁ¤µÈ ŸÀÌ¹Ö ÆÄ¶ó¹ÌÅ͸¦ ÇØ¼®ÇÏ´Â ¹æ¹ýÀ» Áö½ÃÇÏ´Â °æ¿ì¿¡ »ç¿ëÇÕ´Ï´Ù. ¿¹¸¦ µé¾î ´ÙÀ½ÀÇ ÄÚµå´Â ¶ôÀ» »ç¿ëÇÒ ¼ö ¾ø´Â °æ¿ì, 50 ¹Ð¸® ¼¼ÄÁµå ÈÄ¿¡ ŸÀÓ ¾Æ¿ô ÇÕ´Ï´Ù.
Lock lock = ...; if ( lock.tryLock(50L, TimeUnit.MILLISECONDS) ) ...ÀÌ Äڵ尡 50 ÃÊ ÈÄ¿¡ ŸÀÓ ¾Æ¿ô ÇÏ´Â °æ¿ì:
Lock lock = ...; if ( lock.tryLock(50L, TimeUnit.SECONDS) ) ...´Ù¸¸, ƯÁ¤ÀÇ Å¸ÀÓ ¾Æ¿ô ±¸ÇöÀÌ, ÁöÁ¤µÈ TimeUnit¿Í °°Àº ÀÔµµ·Î ½Ã°£ °æ°ú¸¦ ÅëÁöÇÒ ¼ö ÀÖ´Ù°í ÇÏ´Â º¸ÁõÀº ¾ø½À´Ï´Ù.
| ¿°ÅÇü Á¤¼öÀÇ °³¿ä | |
|---|---|
MICROSECONDS
|
|
MILLISECONDS
|
|
NANOSECONDS
|
|
SECONDS
|
|
| ¸Þ¼µå °³¿ä | |
|---|---|
long |
convert (long duration,
TimeUnit unit)
ÁöÁ¤µÈ ´ÜÀ§·Î ³ªÅ¸³»Áö´Â ÁöÁ¤µÈ ±â°£À» ÀÌ ´ÜÀ§·Î º¯È¯ÇÕ´Ï´Ù. |
void |
sleep (long timeout)
ÀÌ ´ÜÀ§¸¦ »ç¿ëÇØ, Thread.sleep¸¦ ½ÇÇàÇÕ´Ï´Ù. |
void |
timedJoin (Thread thread,
long timeout)
ÀÌ ½Ã°£ ´ÜÀ§¸¦ »ç¿ëÇØ, ½Ã°£ ÁöÁ¤µÈ Thread.join¸¦ ½ÇÇàÇÕ´Ï´Ù. |
void |
timedWait (Object obj,
long timeout)
ÀÌ ½Ã°£ ´ÜÀ§¸¦ »ç¿ëÇØ, ½Ã°£ ÁöÁ¤µÈ Object.waitÀ» ½ÇÇàÇÕ´Ï´Ù. |
long |
toMicros (long duration)
MICROSECONDS.convert(duration, this)¿Í °°½À´Ï´Ù. |
long |
toMillis (long duration)
MILLISECONDS.convert(duration, this)¿Í °°½À´Ï´Ù. |
long |
toNanos (long duration)
NANOSECONDS.convert(duration, this)¿Í °°½À´Ï´Ù. |
long |
toSeconds (long duration)
SECONDS.convert(duration, this)¿Í °°½À´Ï´Ù. |
static TimeUnit |
valueOf (String name)
ÁöÁ¤ÇÑ À̸§À» °¡Áö´Â ÀÌ ÇüÅÂÀÇ ¿°ÅÇü Á¤¼ö¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
static TimeUnit [] |
values ()
ÀÌ ¿°ÅÇüÀÇ Á¤¼ö¸¦ Æ÷ÇÔÇÑ ¹è¿ÀÌ ¼±¾ðµÇ°í ÀÖ´Â ¼ø¼·Î ¸®ÅÏÇÕ´Ï´Ù. |
| Ŭ·¡½º java.lang. Enum ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
|---|
clone,
compareTo,
equals,
getDeclaringClass,
hashCode,
name,
ordinal,
toString,
valueOf |
| Ŭ·¡½º java.lang. Object ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
|---|
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
| ¿°ÅÇü Á¤¼öÀÇ »ó¼¼ |
|---|
public static final TimeUnit NANOSECONDS
public static final TimeUnit MICROSECONDS
public static final TimeUnit MILLISECONDS
public static final TimeUnit SECONDS
| ¸Þ¼µåÀÇ »ó¼¼ |
|---|
public static final TimeUnit [] values()
for(TimeUnit c : TimeUnit.values())
System.out.println(c);
public static TimeUnit valueOf(String name)
name - ¸®ÅϵÈ
¿°ÅÇü Á¤¼öÀÇ À̸§
IllegalArgumentException - ÁöÁ¤µÈ À̸§À» °¡Áö´Â Á¤¼ö¸¦ÀÌ ¿°ÅÇüÀÌ °¡Áö°í ÀÖÁö ¾ÊÀº °æ¿ì
public long convert(long duration,
TimeUnit unit)
duration - ÁöÁ¤µÈ unit
±â°£unit - duration ÀμöÀÇ ´ÜÀ§
public long toNanos(long duration)
duration - ±â°£
convert(long, java.util.concurrent.TimeUnit) public long toMicros(long duration)
duration - ±â°£
convert(long, java.util.concurrent.TimeUnit) public long toMillis(long duration)
duration - ±â°£
convert(long, java.util.concurrent.TimeUnit) public long toSeconds(long duration)
duration - ±â°£
convert(long, java.util.concurrent.TimeUnit)
public void timedWait(Object obj,
long timeout)
throws InterruptedException
¿¹¸¦ µé¾î
´ÙÀ½ÀÇ Äڵ带 »ç¿ëÇØ, ºí·Ï ÇÏ´Â poll ¸Þ¼µå¸¦ ±¸ÇöÇÒ ¼ö ÀÖ½À´Ï´Ù (BlockingQueue.poll¸¦
ÂüÁ¶).
public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException {
while (empty) {
unit.timedWait(this, timeout);
...
}
}
obj - ´ë±âÇÏ´Â °´Ã¼timeout - ´ë±âÇÏ´Â ÃÖÀå ½Ã°£
InterruptedException - ´ë±âÁß¿¡ ÀÎÅÍ·´Æ®°¡ ¹ß»ýÇßÀ» °æ¿ìObject.wait(long, int)
public void timedJoin(Thread thread,
long timeout)
throws InterruptedException
thread - ´ë±âÇÏ´Â threadtimeout - ´ë±âÇÏ´Â ÃÖÀå ½Ã°£
InterruptedException - ´ë±âÁß¿¡ ÀÎÅÍ·´Æ®°¡ ¹ß»ýÇßÀ» °æ¿ìThread.join(long, int)
public void sleep(long timeout)
throws InterruptedException
timeout - sleeve ÇÏ´Â ÃÖ´Ü ½Ã°£
InterruptedException - sleeveÁß¿¡ ÀÎÅÍ·´Æ®°¡ ¹ß»ýÇßÀ» °æ¿ìThread.sleep(long)
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| ÀÌÀü Ŭ·¡½º ´ÙÀ½ÀÇ Å¬·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
| °³¿ä: NESTED | ¿°ÅÇü Á¤¼ö | Çʵå | ¸Þ¼µå | »ó¼¼: ¿°ÅÇü Á¤¼ö | Çʵå | ¸Þ¼µå | |||||||||
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy µµ ÂüÁ¶ÇϽʽÿÀ.