Comparison of several methods of java queue entry and exit

 

Insert series

addXXX: throw an exception if the insert is unsuccessful

offerXXX: return false if the insertion is unsuccessful, otherwise return true

putXXX: Insertion is unsuccessful, blocking thread

offerXXX(xx,xx,xx): Insertion is unsuccessful, and it is interrupted after blocking for a certain period of time

 

Delete series

removeXXX: An exception is thrown if the deletion is unsuccessful

pollXXX: return false if the deletion is not successful, otherwise return true

takeXXX: delete unsuccessful, blocking thread

pollXXX(xx,xx,xx): The deletion was unsuccessful, and it was interrupted after blocking for a certain period of time

 

prune:

element() ==getFirst() or getXXX(): returns the element at the head or tail of the team, otherwise an exception will be thrown

peekXXX(): Returns the head or tail element of the team, otherwise returns null

Guess you like

Origin blog.csdn.net/liyang_nash/article/details/108354683