queue

How do I implement my own advanced Producer/Consumer scenario?

ぐ巨炮叔叔 提交于 2019-12-20 05:12:10
问题 NOTE: i did a complete rework of my question. you can see the original question via the change-history. i'm in the need of a "mighty" queue, which provides following functionalities: i have a certain scope for a group of objects. that means that Group A , Group B , ... will have their own queue i'm filling a queue in a group-scoped thread Thread A (Producer) i'm reading a queue in a group-scoped thread Thread B (Consumer) so i will have following scenarios: there is and will be no item in the

How do i set up a DelayQueue's Delay

别等时光非礼了梦想. 提交于 2019-12-20 01:08:43
问题 I'm just starting out coding in java i'm in struggling with setting up a DelayQueue, I wanted to have it so, DelayQueue queue = new DelayQueue(); If (counter > 0){ queue.offer(Integer, *A custom delay*) } Else { queue.offer(Integer, *A different custom delay*) } I'm just trying to learn all the basics and ive read over the API and cant seem to grasp it. Thanks in advance 回答1: The DelayQueue keeps the elements internally until a certain delay has expired. The elements must implement the

How do i set up a DelayQueue's Delay

别来无恙 提交于 2019-12-20 01:08:35
问题 I'm just starting out coding in java i'm in struggling with setting up a DelayQueue, I wanted to have it so, DelayQueue queue = new DelayQueue(); If (counter > 0){ queue.offer(Integer, *A custom delay*) } Else { queue.offer(Integer, *A different custom delay*) } I'm just trying to learn all the basics and ive read over the API and cant seem to grasp it. Thanks in advance 回答1: The DelayQueue keeps the elements internally until a certain delay has expired. The elements must implement the

How to match MQ Server reply messages to the correct request

狂风中的少年 提交于 2019-12-20 01:08:12
问题 I'm connecting to an IBM Websphere MQ. I want to be able to match the reply message with the correct request message. I've trawled through hundreds of pages to get this and have had no luck. I have a class - MQHandler - which sends a message to one defined queue, and reads the request from another. This works fine, however, if multiple users are using the application at the same time, messages get mixed up. I can't seem to get a method on the receiver to indicate the CorrelationID to match.

Is there such a thing as a lockless queue for multiple read or write threads?

坚强是说给别人听的谎言 提交于 2019-12-19 17:18:21
问题 I was thinking, is it possible to have a lockless queue when more than one thread is reading or writing? I've seen an implementation with a lockless queue that worked with one read and one write thread but never more than one for either. Is it possible? I don't think it is. Can/does anyone want to prove it? 回答1: There are multiple algorithms available, I ended up implementing the An Optimistic Approach to Lock-Free FIFO Queues, which avoids the ABA problem via pointer-tagging (needs the

Multithread queue in delphi?

时光毁灭记忆、已成空白 提交于 2019-12-19 11:48:16
问题 This is my second question about this, im having some troubles with this >.< Well, I just want to create a limited number of threads (in this case, I want 10 threads), and then each thread will pick up a name in my list and get some data in my site. My system works pretty well, but my multi thread system still fails =( -- I tried the code posted by LU RD, but the main thread don't wait the threads finish the queue, and just stops =( The code: uses Classes,SyncObjs,Generics.Collections; Type

Multiprocessing process does not join when putting complex dictionary in return queue

╄→гoц情女王★ 提交于 2019-12-19 09:43:08
问题 Given a pretty standard read/write multithreaded process with a read Queue and a write Queue: 8 times worker done is printed, but the join() statement is never passed. But if I replace queue_out.put(r) by `queue_out.put(1) it works. This is melting my brain, probably something really stupid. Should I make a copy of my dictionary and put that in the return Queue? Did I make a stupid mistake somewhere? Process function def reader(queue_in, queue_out, funktion): # Read from the queue while True:

Is there any way to make Go's channels behave like a stack

跟風遠走 提交于 2019-12-19 09:27:25
问题 Go channels by default behave like a queue as far as I can tell, first in first out. Is there any way to change them to work last in first out? Basically I am doing a search and want to do DFS instead of BFS for memory constraints. 回答1: No, this is not possible - channels are always FIFO. You could use package container/heap. 来源: https://stackoverflow.com/questions/17755222/is-there-any-way-to-make-gos-channels-behave-like-a-stack

Why are there no ObservableQueues in JavaFX?

匆匆过客 提交于 2019-12-19 05:56:10
问题 Why are there no ObservableQueue in JavaFX? If we look at the Java 9 documentation (just to see if there are any changes from 8) for FXCollections, we see static helper methods to create Observable sets, lists, and maps. There are also some methods to create Observable float and integer arrays. However, there is no way to create an ObservableQueue. The Queue interface in Java has many interesting implementations, including ArrayDeque, DelayQueue, ConcurrentLinkedQueue, PriorityQueue, etc.

Communicating end of Queue

橙三吉。 提交于 2019-12-19 05:33:09
问题 I'm learning to use the Queue module, and am a bit confused about how a queue consumer thread can be made to know that the queue is complete. Ideally I'd like to use get() from within the consumer thread and have it throw an exception if the queue has been marked "done". Is there a better way to communicate this than by appending a sentinel value to mark the last item in the queue? 回答1: original (most of this has changed; see updates below) Based on some of the suggestions (thanks!) of Glenn