Skip to content

Instantly share code, notes, and snippets.

@rares
Created March 13, 2011 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rares/868171 to your computer and use it in GitHub Desktop.
Save rares/868171 to your computer and use it in GitHub Desktop.
import java.util.concurrent.ArrayBlockingQueue
class Worker extends Runnable {
private val queue = new ArrayBlockingQueue[String](10)
def pushWork(s: String) = queue.put(s)
def run {
while(true) {
for { job <- Option(queue.poll) } yield { println(job) }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment