nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
examples: annotate examples
[nit.git]
/
lib
/
pthreads
/
examples
/
threaded_example.nit
diff --git
a/lib/pthreads/examples/threaded_example.nit
b/lib/pthreads/examples/threaded_example.nit
index
9a0af4b
..
66b2076
100644
(file)
--- a/
lib/pthreads/examples/threaded_example.nit
+++ b/
lib/pthreads/examples/threaded_example.nit
@@
-15,7
+15,7
@@
# limitations under the License.
# test for threaded annotation
# limitations under the License.
# test for threaded annotation
-module threaded_example
+module threaded_example is example
import pthreads
import pthreads
@@
-32,7
+32,17
@@
fun bar(i : Int, s : String) is threaded do
print s
end
print s
end
+# Parameterized `threaded` method with a return type
+fun baz(i : Int, j : Int): Int is threaded do
+ sys.nanosleep(10, 0)
+ return i + j
+end
+
+print "main"
foo
bar(10, "parameterized and threaded")
foo
bar(10, "parameterized and threaded")
-print "main"
sys.nanosleep(5,0)
sys.nanosleep(5,0)
+var x = baz(2, 3)
+print "main, waiting for baz"
+var y = x.join
+print("baz result : " + y.to_s)