title: Executing new threads in order
body: <p>Let me simplify my example. Imagine I have two buttons.</p>
  
  <pre><code>btn_A.setOnClickListener(v -&gt; {
                  // update ROOM DB value to A
              });
  btn_B.setOnClickListener(v -&gt; {
                  // update ROOM DB value to B
              });
  </code></pre>
  
  <p>Button A will set DB value to 'A'.<br>
  Button B will set DB value to 'B'.</p>
  
  <p>Since I cannot access DB from the Main/UI thread, I execute it from the new thread:</p>
  
  <pre><code>btn_A.setOnClickListener(v -&gt; {
      new Thread(() -&gt; {
          // update ROOM DB value to A
      }).start();
  });
  btn_B.setOnClickListener(v -&gt; {
      new Thread(() -&gt; {
          // update ROOM DB value to B
      }).start();
  });
  </code></pre>
  
  <p>If I press Button A, B, A, B..., then I am worried that new threads will not execute consecutively(in sequence).</p>
  
  <p>I thought about using ExecutorService with Executors.newFixedThreadPool(1) but I am not sure if this will run the worker thread in sequence. Also the DB modification commends are called from different Activities/Service so I should make the ExecutorService static. I am worried if I make the ExecutorService static and don't call 'shutdown()', then it may result in memory leak.</p>
  
  <p>I want to avoid implementing my own producer/consumer design pattern with the queue logic. </p>
  
  <p>It feels like there is a simple way to do it but I can't figure it out. :(</p>