Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import core.thread;
- import std.stdio;
- import std.conv;
- shared string[] output;
- shared int threadCount = 0;
- shared int counter = 0;
- void run()
- {
- threadCount++;
- for(int i = 0; i < 10; i++)
- {
- string test = "T"~to!string(threadCount)~": "~to!string(counter++);
- output ~= test;
- }
- }
- int main()
- {
- Thread testThread1 = new Thread(&run);
- Thread testThread2 = new Thread(&run);
- testThread1.start();
- testThread2.start();
- testThread1.join();
- testThread2.join();
- for(int i = 0; i < output.length; i++)
- writeln(output[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement