开发者

Design pattern for managing queues and stacks?

开发者 https://www.devze.com 2022-12-10 18:55 出处:网络
Is there a design pattern for managing a开发者_JAVA百科 queue or a stack? For example, we are looking to manage a list of tasks. These tasks will be added to a group queue, users will then be able to

Is there a design pattern for managing a开发者_JAVA百科 queue or a stack? For example, we are looking to manage a list of tasks. These tasks will be added to a group queue, users will then be able to pull off the queue and add them to their personal queue.


Design patterns can use queues and stacks, but the queues and stacks themselves don't really implement a design pattern, they implement an interface.

Queues are typically FIFO while stacks are LIFO.

Since many users might be using the data structures simultaneously, you should use proper synchronization to avoid concurrency issues.

Are you looking for concurrency-related design patterns to use?


Most frameworks provide some kind of queue and/or stack implementations. E.g. in .NET - System.Collections.Generic.Queue and System.Collections.Generic.Stack

0

精彩评论

暂无评论...
验证码 换一张
取 消