From 0361cfc4d9968d36151754e9e7103a135c3f9ecc Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Wed, 19 Aug 2015 12:51:35 +0300 Subject: [PATCH] Simple threads... --- vala/live.gnome.org_tutorial/build.sh | 2 +- vala/live.gnome.org_tutorial/threads.vala | 2 -- vala/threads/class.vala | 19 +++++++++++++++++++ vala/threads/minimal.vala | 9 +++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 vala/threads/class.vala create mode 100644 vala/threads/minimal.vala diff --git a/vala/live.gnome.org_tutorial/build.sh b/vala/live.gnome.org_tutorial/build.sh index 518077e..c4aa1a0 100755 --- a/vala/live.gnome.org_tutorial/build.sh +++ b/vala/live.gnome.org_tutorial/build.sh @@ -1,6 +1,6 @@ #!/bin/sh -valac --thread threads.vala +valac --thread --target-glib=2.32 threads.vala valac --thread --target-glib=2.32 threads-2.32.vala valac --thread philosophers.vala valac --thread async-queue-test.vala diff --git a/vala/live.gnome.org_tutorial/threads.vala b/vala/live.gnome.org_tutorial/threads.vala index c8b95ac..786a901 100644 --- a/vala/live.gnome.org_tutorial/threads.vala +++ b/vala/live.gnome.org_tutorial/threads.vala @@ -42,5 +42,3 @@ int main () { return 0; } - - diff --git a/vala/threads/class.vala b/vala/threads/class.vala new file mode 100644 index 0000000..7f38c81 --- /dev/null +++ b/vala/threads/class.vala @@ -0,0 +1,19 @@ +public class MyThread { + + private string _s; + + public MyThread (string s) { + _s = s; + } + + public int run () { + stdout.printf ("%s\n", _s); + return 0; + } +} + +void main () { + var mt = new MyThread ("This is my thread is running!\n"); + var t = new Thread ("Debugging thread name", mt.run); + t.join (); +} diff --git a/vala/threads/minimal.vala b/vala/threads/minimal.vala new file mode 100644 index 0000000..d5659a5 --- /dev/null +++ b/vala/threads/minimal.vala @@ -0,0 +1,9 @@ +int thread_func () { + stdout.puts ("Thread is running!\n"); + return 0; +} + +void main () { + var t = new Thread.try ("My thread Debugging name...", thread_func); + t.join (); +}