multithreading - Can't create thread in vala: `GLib.Thread' does not have a default constructor -
this sample programme not compile:
public class myclass { public bool do_work () { message ("other thread: %p", (void*)thread.self ) ; homecoming false ; } public void run () { thread<bool> thread1 = new thread<bool>.try ("queuejobmanager-thread-1", do_work); thread1.join () ; } } int main (string[] args) { message ("main thread: %p", (void*)thread.self ) ; var item = new myclass () ; item.run () ; homecoming 0 ; }
the error is:
vala-thread.vala:10.36-10.51: error: name `try' not exist in context of `glib.thread' thread<bool> thread1 = new thread<bool>.try ("queuejobmanager-thread-1", do_work);
as specified in the sample, have build using alternative --target-glib 2.32
the finish build line is:
valac <your vala file> --target-glib 2.32
multithreading glib vala
No comments:
Post a Comment