It is me again, and I am pretty stuck with porting some code from c# to java. As I now read, there are two main-ways in order to use multithreading in java. There is the creation of a class, which inherits from thread, or the creation of a class, which implements Runnable. (There is also the anonymous approach, I know ).
As I now painfully had to recognize, that porting the multithreading from c# to java could get me to refactor some of my code ( which I would like to avoid as much as possible) .
So, let me say, I have a class CLQueueWorker inheriting from Thread. My parent object (_oParentMAIN ) will keep a reference of this object.
It's "run" method SHOULD do some asynch actions ( which until now are all implemented in _oParentMAIN):
1) dequeue some data from an object, which was filled (and is maintained) in _oParentMAIN -->(my idea is now to create a static variable in CLQueueWorker, and work with this instead of keeping it in the _oParentMAIN).
2) invokes a method-call on ui thread --> Do not know, how to refactor this, because until now This method is a member of _oParentMAIN and I will not be able to invoke its call on the ui thread, because CLQueueWorker does not know this member).
3) invokes another method on ui thread, which is responsible for ui-elements. --> here my problems also will be the same as in point 2.
So, I need some hints how to redesign this in the appropriate way. Let me say, is it possible, that CLQueueWorker (which really spawns another thread) calls methods/throws events to/of _oParentMAIN AND PASSES EXECUTION BACK INTO MAIN thread ?
I hope, I could describe it clearly enough.