Stack 继承 Vector, Vector是线程安全的,每个方法都是 Synchronized关键字。
方法:
push Pushes an item onto the top of this stack
pop Removes the object at the top of this stack and returns that object as the value of this function.
peek Looks at the object at the top of this stack without removing it from the stack.
Queue 接口, ArrayQueue 实现Queue
方法:
add
offer
poll Retrieves and removes the head of this queue,or returns {@code null} if this queue is empty.
element Retrieves, but does not remove, the head of this queue. This method differs from {@link #peek peek} only in that it throws an exception if this queue is empty.
peek Retrieves, but does not remove, the head of this queue,or returns {@code null} if this queue is empty.
本文探讨了Vector如何作为线程安全Stack的基础,以及ArrayQueue如何实现Queue接口。重点介绍了Vector的Synchronized特性,以及push、pop、peek等操作在并发环境中的表现。同时,我们对比了offer、poll和peek方法在Queue中的作用。
2279

被折叠的 条评论
为什么被折叠?



