title: It stops for a while when button is clicked
body: <pre><code>public class green : MonoBehaviour
  {
      private AudioSource source;
      public AudioClip sound;
      static int result = 0;
  
      // Use this for initialization
      void Start()
      {
          StartCoroutine("RoutineCheckInputAfter3Minutes");
          Debug.Log("a");
      }
  
      IEnumerator RoutineCheckInputAfter3Minutes()
      {
          System.Random ran = new System.Random();
          int timeToWait = ran.Next(1, 50) * 1000;
          Thread.Sleep(timeToWait);
  
          source = this.gameObject.AddComponent&lt;AudioSource&gt;();
          source.clip = sound;
          source.loop = true;
          source.Play();
  
          System.Random r = new System.Random();
          result = r.Next(1, 4);
          Debug.Log("d");
  
          yield return new WaitForSeconds(3f * 60f);
  
          gm.life -= 1;
          Debug.Log(gm.life + "값");
          source.Stop();
          Debug.Log("z");
          if (gm.life &gt;= 0)
          {
              StartCoroutine("RoutineCheckInputAfter3Minutes");
          }
      }
  
      // Update is called once per frame
      public void Update()
      {
          if (result == 1 &amp;&amp; gm.checkeat == true)
          {
              Debug.Log("e");
  
              gm.life += 1;
              Debug.Log("j");
              Debug.Log(gm.life + "값");
              source.Stop();
              gm.checkeat = false;
              StopCoroutine("RoutineCheckInputAfter3Minutes");
              StartCoroutine("RoutineCheckInputAfter3Minutes");
          }
          if (result == 2 &amp;&amp; gm.checkshit == true)
          {
              Debug.Log("f");
  
              gm.life += 1;
              Debug.Log("o");
              Debug.Log(gm.life + "값");
              source.Stop();
              gm.checkshit = false;
              StopCoroutine("RoutineCheckInputAfter3Minutes");
              StartCoroutine("RoutineCheckInputAfter3Minutes");
  
          }
          else if (result == 3 &amp;&amp; gm.checksleep == true)
          {
              Debug.Log("g");
              gm.life += 1;
              Debug.Log(gm.life);
              Debug.Log(gm.life + "값");
              source.Stop();
              gm.checksleep = false;
              StopCoroutine("RoutineCheckInputAfter3Minutes");
              StartCoroutine("RoutineCheckInputAfter3Minutes");
          }
      }
  }
  </code></pre>
  
  <p>public class gm : MonoBehaviour
  {</p>
  
  <pre><code>static public int life = 0;
  static public bool checkeat = false;
  static public bool checkshit = false;
  static public bool checksleep = false;
  
  // Use this for initialization
  void Start()
  {
  
  }
  
  // Update is called once per frame
  void Update()
  {
  
  }
  
  public void eating(string eat)
  {
  
      Debug.Log(life + "값");
      checkeat = true;
  }
  
  public void shitting(string shit)
  {
  
      Debug.Log(life + "값");
      checkshit = true;
  }
  
  public void sleeping(string sleep)
  {
  
      Debug.Log(life + "값");
      checksleep = true;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>when i click a button , program stops for a while and then works... i think it is because of thread or something... 
  please share your opinion..
  .when i click a button , program stops for a while and then works... i think it is because of thread or something... 
  please share your opinion..</p>