开发者

Filling SWT table object using a separated thread class

I've got a code snippet by the swt team that does exactly what I need. However, there is a part I want to separate into another class, in particular, the whole inline stuff. In response to my former question, it has been suggested that Callable should be used in order to implement threaded objects. It is suggested to make use of an implementation of runnable or better callable, since I do need some kind of return.

However, I don't get it. My problems are:

  1. In the original code, within the inline implementation of the method run, some of the parents objects are called. How would I do this when the thread is separated? Pass the object via the C'tor's parameter?
  2. In the original code, another runnable object is nested within the runnable implementation. What is it good for? How to implement this when having separated the code? Furthermore, this nested runnable again calls objects created by the main method.

Please, have mercy with me, but I am still quite a beginner and my brain is near col开发者_Go百科lapsing :-( All I want is to separate all the threaded stuff into another class and make the program do just the same thing as it already does. Help please!

Again thank you very much in advance for any useful suggestions, hints, examples etc...

Regs Me


The inner non-static classes in java receive parent instance (for non-static methods) and all final local variables (and method params) they need in the constructor. You can implement this approach yourself - this is ok for large classes.

All UI stuff must be executed in the main thread. That's why nested Runnable object is used. It is added to the event queue by display.syncExec then main thread extracts it somewhen and executes its run method. If you want to create separate class here, you should pass params via constructors or setXXX methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜