Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import queue : Queue;
- import core.thread : Thread;
- class ThreadInput : Thread {
- private Queue!string queue;
- this(Queue!string queue) {
- super(&run);
- this.queue = queue;
- }
- private void run() {
- while (true) {
- queue.put(readln);
- }
- }
- }
- void main() {
- Queue!string inputQueue = new Queue!string;
- ThreadInput threadInput = new ThreadInput(inputQueue);
- threadInput.start;
- while (true) {
- foreach (string value; inputQueue) {
- writeln(value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement