pry/pry — pull request #944 by nviennot (2013-06-25 19:22:24+00:00)
Title: Thread support for REPL

Without the patch, threads are behaving in a funny way when they each have their own REPL:

```
pafy@bisou ~ % pry
[1] pry(main)> Thread.new { Thread.new { "t1".pry } ; "t2".pry; Thread.new { "t3".pry } }
=> #
[1] pry("t2")> 1
=> 1
[2] pry(main)> 2
=> 2
[1] pry("t1")> 3
=> 3
[2] pry("t2")> exit
[3] pry(main)> 4
=> 4
[2] pry("t1")> 5
=> 5
[4] pry(main)> 6
=> 6
[3] pry("t1")> exit
[5] pry(main)> exit7
NameError: undefined local variable or method `exit7' for main:Object
from (pry):8:in `__pry__'
[6] pry(main)>
[7] pry(main)> 7
=> 7
[8] pry(main)> 8
=> 8
[9] pry(main)> 9
=> 9
[1] pry("t3")> exit

[10] pry(main)> exit
```

With the patch:

```
pafy@bisou ~/tmp/pry-threads % pry
[1] pry(main)> Thread.new { Thread.new { "t1".pry } ; "t2".pry; Thread.new { "t3".pry } }
=> #
[1] pry("t1")> 1
[1] pry("t1")> 1
=> 1
[2] pry("t1")> 2
=> 2
[3] pry("t1")> 3
=> 3
[4] pry("t1")> exit
[1] pry("t2")> 4
=> 4
[2] pry("t2")> 5
=> 5
[3] pry("t2")> 6
=> 6
[4] pry("t2")> exit
[1] pry("t3")> 7
[1] pry("t3")> 7
=> 7
[2] pry("t3")> 8
=> 8
[3] pry("t3")> 9
=> 9
[4] pry("t3")> exit
[2] pry(main)> 10
=> 10
[3] pry(main)> 11
=> 11
[4] pry(main)> exit
```