[Vala] Threads and closures problem
- From: JM <interflug1 gmx net>
- To: vala-list gnome org
- Subject: [Vala] Threads and closures problem
- Date: Thu, 14 Jan 2010 00:02:36 +0100
Hi all
I just played around with closures as thread functions. I'm not sure if
this example is supposed to work, but at least it compiles.
class HHH : Object {
public void run() {
string test = "test";
try {
Thread.create( ()=> { print("in thread : %s \n", test); }, false);
}
catch(GLib.ThreadError e) {
print("%s", e.message);
}
}
public static MainLoop loop;
public static int main() {
loop = new MainLoop(null, false);
var h = new HHH();
h.run();
loop.run();
return 0;
}
}
// valac --thread hhh.vala
Problem is that the value in the closure is lost somehow.
The output of this test program is:
$./hhh
in thread : (null)
Anybody knows how this should be handled?
Regards
Jörn
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]