Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a queue of threads  RSS feed

 
Ronald Castillo
Ranch Hand
Posts: 47
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Stephan van Hulst
Saloon Keeper
Posts: 7716
142
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All of this is already done for you. Take a look at BlockingQueue and Executor, both in java.util.concurrent.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!