Say you have Thread A trying to push 20 and Thread B trying to push 30 into the stack, and Thread A got the time slice first.
假设线程A试图把20压入堆栈,线程B 试图压入30,而线程 A 先获得了时间片。
In this example, when main called function1 , it pushed the values for c, then b, then a onto the stack.
在这个例子中,当main调用function1时,它将c的值压入堆栈,然后压入b的值,最后压入a的值。
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压入堆栈后结束。
With this arrangement, even if Thread B has modified the top while Thread a tries to pop, you're sure that no elements in the stack are skipped.
这样,即使线程b在线程A试图弹出数据的同时修改了堆栈顶,也可以确保不会跳过堆栈中的元素。
B: Yes. There is a stack of them by the fax machine.
有,传真机旁边有一沓。
This paper mainly discuses DCS control scheme of steam stack -b...
本文主要就蒸汽链条锅炉燃烧d CS控制方案进行一些探讨。
This paper mainly discuses DCS control scheme of steam stack -b...
本文主要就蒸汽链条锅炉燃烧d CS控制方案进行一些探讨。
应用推荐