This simple design, possible because the data obeys strict LIFO order, means that no complex data structure is needed to track stack contents - a simple pointer to the top of the stack will do.
这种简单的设计,很有可能是考虑到数据操作都符合后进先出(LIFO )规则,这意味着访问栈的内容并不需要复杂的数据结构,一个简单的栈顶指针就能搞定一切。
So, the code loops back, points to the proper top pointer (which was changed because of Thread b), invokes CAS, and is done with pushing 20 into the stack.
因此,代码回到循环的开头,指向正确的top指针(线程b修改后的),调用CAS,把20压入堆栈后结束。
If a function is executing, then the stack pointer is pointing to the top of the whole stack, which is also the top of that function's activation record.
如果一个函数正在执行,那么堆栈指针就会指向整个堆栈的顶部,这也是该函数活动记录的顶部。
应用推荐