title: Right way to create threads in a J2EE webapp - PMD DoNotUseThreads violation
body: <p>I am trying to create a task inside my webapp, which runs in a thread of it's own. It is a monitoring task that should run for the entire duration of the application. For this purpose, I have created a class that looks like:</p>
  
  <pre><code>public class MonitoringTask implements Runnable {
      @Override
      public void run() {
         // perform monitoring task action
      }
  }
  </code></pre>
  
  <p>However, I get the "PMD.DoNotUseThreads" error mentioned <a href="http://pmd.sourceforge.net/pmd-4.3.0/rules/j2ee.html" rel="nofollow" title="here">here</a>. If creating threads by implementing Runnable is not the recommended way in a J2EE webapp, what is?</p>