Project

General

Profile

Could you give me some examples how to use the attach Thread?

Added by Everton Fonseca about 6 years ago

exemple#1

new Thread(()->{

//change something

}).start();

//calling

WApplication.getInstance().attachThread(true);

//end exemole#1

can I do it?


Replies (2)

RE: Could you give me some examples how to use the attach Thread? - Added by Wim Dumon almost 6 years ago

Hey,

You'll have to call attachThread() in the new thread.

Also, calling attachThread() manually (and not having it as a consequence of grabbing the update lock) is a tell-tale signal of interacting with the widget tree without holding the lock.

final WApplication theApp = WApplication.getInstance();
new Thread(()->{
  theApp.attachThread(true);
  //change something
  // actually, to change something you should have grabbed theApp's updatelock.
}).start();

Wim.

    (1-2/2)