title: Running two tasks simultaneously in Java
body: <p>I have two tasks that should be run together.
  The first task to save the data to the database. And the second task of recording video.</p>
  
  <p>Currently I use a Thread for each task, and run it simultaneously.</p>
  
  <pre><code>...
  Thread insertDb = new Thread(new Runnable() {
              @Override
              public void run() {
                  // Insert to Database
                  setDataMediaVisit(thumbStr);
                  insertVisitRecord();
              }
          });
  
          Thread capture = new Thread(new Runnable() {
              @Override
              public void run() {
                  if (getGraph().getState() == DSCapture.PREVIEW) {
                      getGraph().setCaptureFile("data/"+ CaptureController.getNoMr() +"/videos/"+videoStr, DSFilterInfo.filterInfoForProfile(new File("profiles/demo_profile800x570_WM8_VBR_100.prx")), DSFilterInfo.doNotRender(), true);
                      getGraph().record();
                  }
  
                  setData(CaptureController.getNoMr());
              }
          });
  
          insertDb.start();
          capture.start();
  ...
  </code></pre>
  
  <p>Is the above code thread safe?
  I want to use EDT, but i know EDT for Java Swing Component. CMIIW</p>
  
  <p>Thank you.</p>