Skip to content

Commit

Permalink
remove java code from scala snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
endform committed Nov 1, 2012
1 parent 033bb6a commit a9193d0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions web/concurrency.textile
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,17 @@ A common pattern for async computation is to separate producers from consumers a
import java.util.concurrent.{BlockingQueue, LinkedBlockingQueue}

// Concrete producer
class Producer[T](path: String, queue: BlockingQueue[T]) implements Runnable {
public void run() {
class Producer[T](path: String, queue: BlockingQueue[T]) extends Runnable {
def run() {
Source.fromFile(path, "utf-8").getLines.foreach { line =>
queue.put(line)
}
}
}

// Abstract consumer
abstract class Consumer[T](queue: BlockingQueue[T]) implements Runnable {
public void run() {
abstract class Consumer[T](queue: BlockingQueue[T]) extends Runnable {
def run() {
while (true) {
val item = queue.take()
consume(item)
Expand Down

0 comments on commit a9193d0

Please sign in to comment.