title: Calling methods from a running Thread
body: <p>So I am trying to make a music player that runs on a separate thread. I want to have methods inside of the Player class (that implements Runnable) to pause, play and go to next/prev song. If I was to call inner methods of the Thread, would it still run on a separate thread? Everything works as it should, but I am still new to Threads so I'm not sure if this is good practice or not. Could someone shed some light on this? </p>
  
  <pre><code>class Player implements Runnable, OnCompletionListener {
      public static final String TAG = "Player";
      private MediaPlayer mp;
      private boolean isPlaying = false;
      private SongsManager sm = null;
      private ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      private int currentSongIndex = 0;
  
      public Player(int currentSongIndex){
          mp = new MediaPlayer();
          mp.setOnCompletionListener(this);
          sm = new SongsManager();
          songsList = sm.getSongList();
          this.currentSongIndex = currentSongIndex;
      }
  
      @Override
      public void run() {
          try{
              mp.reset();
              mp.setDataSource(songsList.get(currentSongIndex).get(SongsManager.KEY_PATH));
              mp.prepare();
              mp.start();
              isPlaying = true;
          } catch (IllegalArgumentException e){
              e.printStackTrace();
          } catch (IllegalStateException e){
              e.printStackTrace();
          } catch (IOException e){
              e.printStackTrace();
          }
      }
  
      public synchronized void pause() {
          if (isPlaying){
              if (mp != null){
                  mp.pause();
                  isPlaying = false;
              }
          }
      }
  
      public synchronized void play() {
          if (!isPlaying){
              if (mp != null){
                  mp.start();
                  isPlaying = true;
              }
          }
      }
      ...
  }
  </code></pre>
  
  <p>So say, if I created a new Thread like so, </p>
  
  <pre><code>Player player = new Player(0);
  playerThread = new Thread(player, Player.TAG);
  playerThread.start();
  </code></pre>
  
  <p>and called player.pause(), then player.play() from a different thread, would the player still be running on the separate thread?</p>