Tagged Questions
1
vote
3answers
43 views
Java Queue Implementation
I am new to Java and trying to use:
public static ArrayBlockingQueue<String> qu=new ArrayBlockingQueue<>(900);
...
qu.enqueue(MyString);
or
public static Queue<String> qu=new ...
0
votes
2answers
29 views
Enqueue, Dequeue and ViewQueue in Java
I am doing a queue in java. Here is my code:
public class ListQueue {
public static void main(String[] args){
Queue myQueue;
Scanner sc = new Scanner(System.in);
String input;
int ...
0
votes
4answers
36 views
Using instance variable Linkedlist() in method - why do I have to make new in method body
this is my first post here. I have recently started to get interested in learning Java, I have read through some beginner level tutorials, kept http://docs.oracle.com as my bookmark and read several ...
-1
votes
0answers
33 views
Which implementation of java queue should be used [closed]
This is a version of queue is used when there is not issue of threading involved. NOTE: All previous questions asked had explanations of when / what to use in case of threading and sync.
Consider a ...
-2
votes
0answers
18 views
PriorityQueue sorting by edge weight [closed]
I want to put edges from a Linked List into a Priority Queue and sort them by their weight, however my function doesn't sort correctly.
The method:
public Graph toMinSpanTree() {
...
1
vote
0answers
19 views
How to store data with database batch, efficiently and persistently?
I want to store data which is actually a 1000 character text data, fast into database. How fast? Let's say 1000 data per second.
To be efficient, I use database feature called "batch insert". This is ...
0
votes
5answers
54 views
When to use queue over arraylist
One basic argument to use a Queue over an ArrayList is that Queue gurnatees FIFO behavior.
But if I add 10 elements to an ArrayList and then iterate over the elemetns starting from the 0th elements, ...
0
votes
1answer
18 views
Is there any Queue implementation that restricts the capacity at creation time?
Both ArrayDeque and PriorityQueue work as an ArrayList in those terms.. it grows as needed.
I read that if using .add(E e) in a queue which has its capacity full it will throw an ...
3
votes
1answer
41 views
blocked in sending to unbounded LinkedBlockingQueue unless there is no receiver?
I have a simple program to generate inputs to CRC32 which output a number ending with 123456 (in hex). It does bruteforce in a worker thread (the next step would be to make multiple worker threads). ...
0
votes
1answer
61 views
Java - ThreadPool with two queues. Or two queues in one
Short version - I'm looking for the most efficient way to wrap two queues into one for use in a thread pool where priority is given to the content of one of the queues as long as it is non-empty and ...
1
vote
2answers
43 views
Producer Consumer Blocking Queue
I have a situation where I have multiple producers and single consumer.
For performance reasons I don't want consumer to be in any kind of blocking, but since there can be more producers they should ...
3
votes
4answers
89 views
Sorting an array with Stacks and Queues
I need to create a method which sorts an array of integers using a Stack and a Queue. For instance if given [-1, 7, 0, 3, -2] -> [-2, -1, 0, 3, 7]. I'm completely lost at how to do this question, ...
3
votes
2answers
36 views
Synchronized Circular Queue
I am implementing a very simple synchronized Circular Queue as it follows , a friend of mine says that it's prone to deadlock ! but I don't believe so ,
actually when a thread wants to dequeue ...
2
votes
2answers
38 views
Java Azure ServiceBusService listQueues() capped at 100 queues?
I'm using the Azure SDK in Eclipse, and I'm attempting to retrieve a list of all the queues associated with a service bus. I'm able to properly connect to the service bus, but when I call listQueues ...
0
votes
2answers
20 views
Selecting specific elements and printing the number of them in a Queue
i created a queue (generic) that has a String and time-stamp value as each element. Now i'm trying to select elements that have their timestamps older than an hour and printing out their sums and ...