title: Run only one thread with ThreadPoolExecutor()
body: <p>I used ThreadPoolExecutor() to run multiple threads for my application. I want to take a test with single thread so I set nb_threads = 1 in this case. But I'm not sure that it's correct so can you help me take only one thread, please?</p>
  
  <p>Here it's my part of code: </p>
  
  <pre><code>private ThreadPoolExecutor executor = null;
  public static int NB_THREADS_MAX = 8;
  
  public void submit(Runnable inRunnable) {
          if (executor == null) {
  
          /*Choice exactly the number of threads that relates the number of available processors*/
          nb_threads = NB_THREADS_MAX &lt; (tmp = Runtime.getRuntime().availableProcessors())
                        ? NB_THREADS_MAX
                        : tmp;
          executor = new ThreadPoolExecutor(nb_threads, nb_threads, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue&lt;Runnable&gt;()); /*In this case, the pool size is fixed*/
          }
  
          executor.submit(inRunnable);
  }
  </code></pre>