Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Deuce STM排队_Java_Multithreading_Transactions_Atomic_Stm - Fatal编程技术网

Java 使用Deuce STM排队

Java 使用Deuce STM排队,java,multithreading,transactions,atomic,stm,Java,Multithreading,Transactions,Atomic,Stm,我是Deuce STM的新手,想知道如何使用Deuce STM实现队列。以下是我目前的工作执行情况- Node类包含两个字段—值和指向下一个字段的指针 public class STMQueue { Node head, tail; public STMQueue() { Node sentinel = new Node(-1); tail = sentinel; head = sentinel; } @Atomic public void enq(int x)

我是Deuce STM的新手,想知道如何使用Deuce STM实现队列。以下是我目前的工作执行情况-

Node类包含两个字段—值和指向下一个字段的指针

public class STMQueue {

Node head, tail;

public STMQueue() {
    Node sentinel = new Node(-1);

    tail = sentinel;
    head = sentinel;
}

@Atomic
public void enq(int x) {
    Node node = new Node(x);
    tail.next = node;       
    tail = node;
}

@Atomic
public int deq() throws EmptyException{
    Node node = head.next;
    if(node == null) {
        throw new EmptyException();
    }
    int retVal = node.value;
    head = node;
    return retVal;
}

}
这是正确的实施方式吗?我们必须手动抛出事务异常吗?如果这是正确的,那么我们如何衡量中止的事务数
还是重试?

我从未与DeuceSTM合作过。话虽如此,有几点值得注意:

看来你的空头支票是错的;根据构造函数,如果node==sentinel,则应为。 从盖伊·科兰(Guy Korland)那里,我相信统计数据并没有得到实施;您必须修改上下文对象,看起来。。。