Forums Register Login

Creating a queue of threads

+Pie Number of slices to send: Send
I want to create some kind of queue for an app.
The idea is pretty much like this: user starts using the app and gets in line (queue), now the more users that come in, obviously, the more elements I'll have in my queue. Now, I want each element to do "something" in the same order they came in (FIFO, first in first out). The other elements in line won't have access to that "something" until the current thread is over.

I'm not very skilled when it comes to threads, so, what can I do? How can I accomplish this "queue" thing?

Thanks in advance

EDIT: Since it's a server/client app, I can have a sync'd method that does the processing. Now, how can I make threads come in in the same order they were created?
1
+Pie Number of slices to send: Send
All of this is already done for you. Take a look at BlockingQueue and Executor, both in java.util.concurrent.
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 559 times.
Similar Threads
Order of messages with multiple mdb's
Handling Uploaded Files
Logical/File Locking and nested synchronisation
Web interface to delete folder
Passed SCJD with 359/400
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:41:34.