Themes are often designed in two ways ( see java tutorials ): either by extending the Thread class, or by implementing the Runnable class. In any case, you need to specify what will work inside the stream.
I developed a class, an adapter to an online resource that retrieves various kinds of information. This class consists of methods such as getInformationOfTypeA () and getInformationOfTypeB (). Both contain code for connecting to online resources, so both of them must be streamed to avoid deadlocks.
The question is, how do I create this? I can do this as shown below, but then I can only implement one method:
public class OnlineResourceAdapter implements Runnable { public void run() {
Another way would be to create separate classes for each method, but that seems unnatural to me.
Btw: I am developing my application in j2me
UPDATE:
Thanks to your answers, I think that is most suitable for use as methods of the following type:
What do you think about this:
public class OnlineResourceAdapter{ public void getInformationOfTypeA(){ Thread t = new Thread(new Runnable() { public void run() {
What do you think about this?
java multithreading java-me
hsmit
source share