java.util.concurrent.atomic
Ŭ·¡½º AtomicReferenceFieldUpdater<T, V>
java.lang.Object
java.util.concurrent.atomic.AtomicReferenceFieldUpdater<T, V>
- ÇüÅ ÆÄ¶ó¹ÌÅÍ:
T
- °»½Å °¡´ÉÇÑ Çʵ带 º¸°ü À¯ÁöÇÏ´Â °´Ã¼ÀÇ ÇüÅÂV
- ÇʵåÀÇ ÇüÅÂ
public abstract class AtomicReferenceFieldUpdater<T, V>
- extends Object
ÁöÁ¤µÈ Ŭ·¡½ºÀÇ ÁöÁ¤µÈ volatile ÂüÁ¶ ÇʵåÀÇ ¿øÀÚ °»½ÅÀÌ °¡´ÉÇÑ, ¸®Ç÷º¼Ç º£À̽ºÀÇ À¯Æ¿¸®Æ¼ÀÔ´Ï´Ù. ÀÌ Å¬·¡½º´Â µ¿ÀÏ ³ëµåÀÇ º¹¼öÀÇ ÂüÁ¶ Çʵ尡 µ¶¸³ÇØ ¿øÀÚ °»½ÅÀÇ ´ë»óÀÌ µÇ´Â ¿øÀÚ µ¥ÀÌÅÍ ±¸Á¶¿¡¼ÀÇ »ç¿ëÀ» ¿°µÎ¿¡ µÎ¾î ¼³°èµÇ°í ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î
Æ®¸® ³ëµå´Â ´ÙÀ½°ú °°ÀÌ ¼±¾ðµË´Ï´Ù.
class Node {
private volatile Node left, right;
private static final AtomicReferenceFieldUpdater<Node, Node> leftUpdater =
AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "left");
private static AtomicReferenceFieldUpdater<Node, Node> rightUpdater =
AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "right");
Node getLeft() { return left; }
boolean compareAndSetLeft(Node expect, Node update) {
return leftUpdater.compareAndSet(this, expect, update);
}
// ... and so on
}
ÀÌ Å¬·¡½º³»ÀÇ compareAndSet ¸Þ¼µåÀÇ º¸ÁõÀº ´Ù¸¥ ¿øÀÚ Å¬·¡½º³»ÀÇ ±×°Íº¸´Ù ¾àÇÑ °Í¿¡ À¯ÀÇÇØ ÁÖ¼¼¿ä. ÀÌ Å¬·¡½º´Â ÇʵåÀÇ »ç¿ë ¸ðµç °ÍÀÌ ¿øÀÚ ¾×¼¼½º¿¡ ÀûÀýÇϰí ÀÖ´Â °ÍÀ» º¸ÁõÇÒ ¼ö ¾ø±â ¶§¹®¿¡
compareAndSet ¹× set ¿Ü È£Ãâ¿¡ °üÇÑ º¸°í ¿øÀÚ¼º ¹× Èֹ߼º ½Ã¸àƽ½º¸¦ º¸ÁõÇÒ ¼ö ÀÖ½À´Ï´Ù.
- µµÀÔµÈ ¹öÀü
:
- 1.5
¸Þ¼µå °³¿ä |
abstract boolean |
compareAndSet (T obj,
V expect,
V update)
¡¸ÇöÀçÀÇ °ª == ¿¹»óµÇ´Â °ª¡¹ÀÎ °æ¿ì, ÀÌ Updater°¡ °ü¸®ÇÏ´Â ÁöÁ¤µÈ °´Ã¼ÀÇ Çʵ尪À» ¿øÀÚÀûÀ¸·Î ¼³Á¤ÇÕ´Ï´Ù. |
abstract V |
get (T obj)
ÁöÁ¤µÈ °´Ã¼°¡ º¸°ü À¯ÁöÇÏ´Â Çʵ峻ÀÇ ÇöÀç°¡¸¦ ÃëµæÇÕ´Ï´Ù. |
V |
getAndSet (T obj,
V newValue)
ÁöÁ¤µÈ °ªÀ¸·Î ¼³Á¤ÇØ, ÀÌÀüÀÇ °ªÀ» ¸®ÅÏÇÕ´Ï´Ù. |
static
|
newUpdater (Class <U> tclass,
Class <W> vclass,
String fieldName)
ÁöÁ¤µÈ Çʵ带 °¡Áö´Â °´Ã¼ÀÇ ¾÷ µ¥ÀÌÅ͸¦ ÀÛ¼ºÇÕ´Ï´Ù. |
abstract void |
set (T obj,
V newValue)
ÀÌ ¾÷ µ¥ÀÌÅÍ¿¡ ÀÇÇØ °ü¸®µÇ´Â ÁöÁ¤µÈ °´Ã¼ÀÇ Çʵ带 ¼³Á¤ÇÕ´Ï´Ù. |
abstract boolean |
weakCompareAndSet (T obj,
V expect,
V update)
¡¸ÇöÀçÀÇ °ª == ¿¹»óµÇ´Â °ª¡¹ÀÎ °æ¿ì, ÀÌ Updater°¡ °ü¸®ÇÏ´Â ÁöÁ¤µÈ °´Ã¼ÀÇ Çʵ尪À» ¿øÀÚÀûÀ¸·Î ¼³Á¤ÇÕ´Ï´Ù. |
Ŭ·¡½º java.lang. Object ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
AtomicReferenceFieldUpdater
protected AtomicReferenceFieldUpdater()
- ¼ºê Ŭ·¡½º¿¡ ÀÇÇØ »ç¿ëµÈ´Ù, ¾Æ¹«°Íµµ ½Ç½ÃÇÏÁö ¾Ê´Â protected constructor¡¡ ¡¡.
newUpdater
public static <U, W> AtomicReferenceFieldUpdater <U, W> newUpdater(Class <U> tclass,
Class <W> vclass,
String fieldName)
- ÁöÁ¤µÈ Çʵ带 °¡Áö´Â °´Ã¼ÀÇ ¾÷ µ¥ÀÌÅ͸¦ ÀÛ¼ºÇÕ´Ï´Ù. Class Àμö´Â ¸®Ç÷ºÆ®
Çü°ú ¹ü¿ëÇüÀÇ ÀÏÄ¡¸¦ üũÇϱâ À§Çؼ ÇÊ¿äÇÕ´Ï´Ù.
- ÆÄ¶ó¹ÌÅÍ:
tclass
- Çʵ带 º¸°ü À¯ÁöÇÏ´Â °´Ã¼ÀÇ Å¬·¡½ºvclass
- ÇʵåÀÇ Å¬·¡½ºfieldName
- °»½ÅÇÏ´Â ÇʵåÀÇ À̸§
- ¹Ýȯ°ª:
- ¾÷ µ¥ÀÌÅÍ
- ¿¹¿Ü:
IllegalArgumentException
- Çʵ尡 Èֹ߼ºÀÇ ÂüÁ¶ÇüÀÌ ¾Æ´Ñ °æ¿ì
RuntimeException
- Ŭ·¡½º¿¡ Çʵ尡 Æ÷ÇÔµÇÁö ¾Ê´Â°¡ ÇüŰ¡ ºÎÁ¤ÇÑ °æ¿ì¿¡
»óÀÚ·Î µÈ ¸®Ç÷º¼Ç º£À̽ºÀÇ ¿¹¿Ü°¡ Throw µÈ´Ù
compareAndSet
public abstract boolean compareAndSet(T obj,
V expect,
V update)
- ¡¸ÇöÀçÀÇ °ª == ¿¹»óµÇ´Â °ª¡¹ÀÎ °æ¿ì, ÀÌ Updater°¡ °ü¸®ÇÏ´Â ÁöÁ¤µÈ °´Ã¼ÀÇ Çʵ尪À» ¿øÀÚÀûÀ¸·Î ¼³Á¤ÇÕ´Ï´Ù. ÀÌ ¸Þ¼µå´Â compareAndSet ¹× set¿¡ ´ëÇÑ ´Ù¸¥ È£Ãâ·Î ¿øÀÚ¼ºÀ» °¡Áö´Â °ÍÀÌ º¸ÁõµÇ°í ÀÖ½À´Ï´Ù¸¸, Çʵ峻ÀÇ ´Ù¸¥ º¯°æ¿¡ °üÇØ¼´Â ¹Ýµå½Ã ±×·¸´Ù¶ó°í´Â ÇÑÁ¤ÇÏÁö ¾Ê½À´Ï´Ù.
- ÆÄ¶ó¹ÌÅÍ:
obj
- Á¶°ÇºÎ·Î Çʵ带 ¼³Á¤ÇÏ´Â °´Ã¼expect
- ¿¹»óµÇ´Â °ªupdate
- »õ·Î¿î °ª
- ¹Ýȯ°ª:
- ¼º°øÇßÀ» °æ¿ì´Â true
weakCompareAndSet
public abstract boolean weakCompareAndSet(T obj,
V expect,
V update)
- ¡¸ÇöÀçÀÇ °ª == ¿¹»óµÇ´Â °ª¡¹ÀÎ °æ¿ì, ÀÌ Updater°¡ °ü¸®ÇÏ´Â ÁöÁ¤µÈ °´Ã¼ÀÇ Çʵ尪À» ¿øÀÚÀûÀ¸·Î ¼³Á¤ÇÕ´Ï´Ù. ÀÌ ¸Þ¼µå´Â compareAndSet ¹× set¿¡ ´ëÇÑ ´Ù¸¥ È£Ãâ·Î ¿øÀÚ¼ºÀ» °¡Áö´Â °ÍÀÌ º¸ÁõµÇ°í ÀÖ½À´Ï´Ù¸¸, Çʵ峻ÀÇ ´Ù¸¥ º¯°æ¿¡ °üÇØ¼´Â ¹Ýµå½Ã ±×·¸´Ù¶ó°í´Â ÇÑÁ¤ÇÏÁö ¾Ê½À´Ï´Ù. À̰ÍÀº ¿Ü°ü»ó ½ÇÆÐÇÏ´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù.
- ÆÄ¶ó¹ÌÅÍ:
obj
- Á¶°ÇºÎ·Î Çʵ带 ¼³Á¤ÇÏ´Â °´Ã¼expect
- ¿¹»óµÇ´Â °ªupdate
- »õ·Î¿î °ª
- ¹Ýȯ°ª:
- ¼º°øÇßÀ» °æ¿ì´Â true
set
public abstract void set(T obj,
V newValue)
- ÀÌ ¾÷ µ¥ÀÌÅÍ¿¡ ÀÇÇØ °ü¸®µÇ´Â ÁöÁ¤µÈ °´Ã¼ÀÇ Çʵ带 ¼³Á¤ÇÕ´Ï´Ù. ÀÌ Á¶ÀÛÀº ÈļÓÀÇ compareAndSet
È£Ãâ¿¡ °üÇØ¼´Â Èֹ߼º ½ºÅä¾î·Î¼ µ¿ÀÛÇÏ´Â °ÍÀÌ º¸ÁõµÇ°í ÀÖ½À´Ï´Ù.
- ÆÄ¶ó¹ÌÅÍ:
obj
- Çʵ带 ¼³Á¤ÇÏ´Â °´Ã¼newValue
- »õ·Î¿î °ª
get
public abstract V get(T obj)
- ÁöÁ¤µÈ °´Ã¼°¡ º¸°ü À¯ÁöÇÏ´Â Çʵ峻ÀÇ ÇöÀç°¡¸¦ ÃëµæÇÕ´Ï´Ù.
- ÆÄ¶ó¹ÌÅÍ:
obj
- Çʵ带 ¾ò´Â °´Ã¼
- ¹Ýȯ°ª:
- ÇöÀçÀÇ °ª
getAndSet
public V getAndSet(T obj,
V newValue)
- ÁöÁ¤µÈ °ªÀ¸·Î ¼³Á¤ÇØ, ÀÌÀüÀÇ °ªÀ» ¸®ÅÏÇÕ´Ï´Ù.
- ÆÄ¶ó¹ÌÅÍ:
obj
- Çʵ带 Ãëµæ ¹× ¼³Á¤ÇÏ´Â °´Ã¼newValue
- »õ·Î¿î °ª
- ¹Ýȯ°ª:
- ÀüÀǰª
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy µµ
ÂüÁ¶ÇϽʽÿÀ.