Note that there are some explanatory texts on larger screens.

plurals
  1. POExecutor and Daemon in Java
    text
    copied!<p>I have a MyThread object which I instantiate when my app is loaded through the server, I mark it as a Daemon thread and then call <code>start()</code> on it. The thread is meant to sit and wait for information from a queue as long as the application is active. My problem/question is this: Currently MyThread is extending Thread because I mark it as Daemon and I read about how it's more prefferable to implement Runnable and to use Executors. So what I wanted to ask is if MyThread will implement Runnable instead of extending Thread (and of course will be renamed) and I'll use <code>newSingleThreadScheduledExecutor()</code> how, what or maybe where, do I mark something as Daemon. I hope I haven't made a mess of terms, please excuse me if I have as some parts of the multithreading environment are very new to me.</p> <p>Thanks Ittai</p> <p>Update: The module I'm referring to in my app is a web-app which has a few threads actually of this sort and what they do have in common is that they all in the <code>ServletContext</code> as a member for various reasons. Currently I extend <code>Thread</code> to <code>WebThread</code> which has the <code>ServletContext</code> as a memebr and all subclasses can utilize this. If I switch over to the Runnable paradigm with the Executor and ThreadFactory than basically I need to have an ugly hybrid of <code>WebRunnable</code> which implements <code>Runnable</code> and has the <code>ServletContext</code> as a public member and have my <code>ThreadFactory</code> implement <code>newThread(WebRunnable arg0)</code> in addition to <code>newThread(Runnable arg0)</code>. I'm not sure what's best. Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload