twitter/scala_school — pull request #124 by prafulliu (2014-05-09 04:50:30+00:00)
Title: fix bugs in concurrency chapter, "A solution: Producer/Consumer" section

At the end of the ***concurrency*** chapter, there is a demo named ***A solution: Producer/Consumer*** has some bugs.

I also fixed them in *Russian*, *Korea* and *Chinese*.

1.
```sh
val queue = new LinkedBlockingQueue[String]()
```
But the other code use ```q``` for this instance, so it's an error.
2.
```sh
for (i <- i to cores) {
```
The second ```i``` is error, it should be ```1```.
3.
```sh
pool.submit(new IndexerConsumer[String](index, q))
```
```index``` is not declared.

4.
```sh
class Producer[T](path: String, queue: BlockingQueue[T]) extends Runnable {
def run() {
Source.fromFile(path, "utf-8").getLines.foreach { line =>
queue.put(line)
}
}
}
```
```sh
val q = new LinkedBlockingQueue[String]()
val producer = new Producer[String]("users.txt", q)
```
```queue.put(line)``` in ```Producer``` class will call an error.
```sh
error: type mismatch;
found : String("sssssssssss")
required: T
b.tell("sssssssssss")
^
one error found
```
Change it to
```sh
class Producer[T>:String](path: String, queue: BlockingQueue[T]) extends Runnable {
```
or
```sh
class Producer[T](path: String, queue: BlockingQueue[String]) extends Runnable {
```
can fix it.