From: BlackMinou Date: Wed, 1 Apr 2015 06:57:42 +0000 (+0200) Subject: Modify example to add a parametrized threaded fun X-Git-Tag: v0.7.4~2^2~4 X-Git-Url: http://nitlanguage.org Modify example to add a parametrized threaded fun Signed-off-by: BlackMinou --- diff --git a/lib/pthreads/examples/threaded_example.nit b/lib/pthreads/examples/threaded_example.nit index 175c753..9a0af4b 100644 --- a/lib/pthreads/examples/threaded_example.nit +++ b/lib/pthreads/examples/threaded_example.nit @@ -19,12 +19,20 @@ module threaded_example import pthreads -# the "is threaded" annotation makes this fun run on an other thread +# the `is threaded` annotation makes this method run on an other thread fun foo is threaded do sys.nanosleep(1,0) print "threaded" end +# Parameterized `threaded` method, same as foo, but with parameters +fun bar(i : Int, s : String) is threaded do + sys.nanosleep(2, 0) + print i + print s +end + foo +bar(10, "parameterized and threaded") print "main" -sys.nanosleep(2,0) +sys.nanosleep(5,0) diff --git a/tests/sav/threaded_example.res b/tests/sav/threaded_example.res index 050d79d..e90aa48 100644 --- a/tests/sav/threaded_example.res +++ b/tests/sav/threaded_example.res @@ -1,2 +1,4 @@ main threaded +10 +parameterized and threaded