29 lines
503 B
Plaintext
29 lines
503 B
Plaintext
'input.txt' as src_file
|
|
|
|
class Queue
|
|
|
|
new list as items
|
|
condition as ready
|
|
|
|
define item_put
|
|
items push ready notify
|
|
|
|
define item_get
|
|
items empty if ready wait
|
|
items shift
|
|
|
|
Queue as lines
|
|
Queue as count
|
|
|
|
thread reader
|
|
"file://r:%(src_file)s" open each lines.item_put
|
|
NULL lines.item_put count.item_get "reader: %d\n" print
|
|
|
|
thread writer
|
|
0 repeat lines.item_get dup while
|
|
"writer: %s" print 1+
|
|
drop count.item_put
|
|
|
|
reader as r
|
|
writer as w
|