Consumer doesn't work in my simple producer/consumer/queue code in Java
问题 I am trying to implement a simple producer/consumer system in Java 11. Basically, I take two threads for each, plus a global queue, simply as follows: A global priority queue. The first thread, producer, runs a HTTP server, listens to incoming http messages, and upon receiving a message, pushes it as a job to the queue ( queue.size increments) The second thread, the consumer, continously peeks the queue. If there is a job ( job ! = null ), submits a HTTP request somewhere and upon successful