-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththread_test.ft
More file actions
35 lines (31 loc) · 925 Bytes
/
thread_test.ft
File metadata and controls
35 lines (31 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
num thread_1 = ${
while (1) {
scope m = receive ();
if (m:message == "exit") {
print ("exit signal received by thread ");
print (m:sender);
break;
}
pstr := 'Message "';
pstr = cat(pstr, m:message);
pstr = cat(pstr, '" received from thread ');
pstr = cat(pstr, str(m:sender));
print(cat(pstr,"\n"));
}
print ("Thread 1 exiting now.\n");
send (0, "done");
};
send (thread_1, "Hello there!");
send (thread_1, "Im glad this works!");
send (thread_1, "now lets complicate things even further...");
num thread_2 = ${
# Wait for a message of a thread id, and then send a message to that thread.
scope m = receive ();
send (m:message, "exit");
print ("Thread 2 exiting now.\n");
};
send (thread_1, "are you ready thread 1? Actually I dont care!");
send (thread_2, thread_1);
send (thread_1, "and we're done!");
receive();
print (" and that's the show folks!\n");