public void run() {
    try {
      Wait_forLab();
    } catch (InterruptedException e) {
    }

    enterLab();
    Think_AskTypeA();
    AddInTurnSeq_for_B();
    CheckAndWait_UntilChatSessionStarts(); // Check_online chat session starts or not ?
    Think_AskTypeB(); //  Student done with his chat Session
    BrowsingAndWait_UntilOfficeHourEnds();

    if (Number != P1.numOfStudents - 1) {
      try {

        p1.mutex.acquire();

        msg("Joined the Queue to Leave from Lab in Descending Order");
        stud[Number + 1].join();
        msg("Student LEAVES the Lab");
        p1.mutex.release();
        // FinalDescendingCheck();

      } catch (InterruptedException ex) {
      }
    } else {
      Terminate();
      msg("Student LEAVES the Lab");
    }
  }
 public void enterLab() {
   if (Number < P1.LabCapacity) {
     msg(" Enters the Lab");
   } else {
     msg("No Entry in Lab...LAB is FULL");
     this.stop(); // Terminating Over Lab Capacity Students
   }
 }
  public void Think_AskTypeA() { // Email and no immediate answer needed

    // Add for loop to send multiple Type A questions by Student A

    for (int i = 1;
        i <= Type_A_Num;
        i++) { // Type_A_Num = Still need to be selected randomly in Constructor

      // Put a message of thinking of a question if u want too
      yield(); // Student Thinking Abt. Type A

      try {
        Thread.sleep(
            random()); // Student Thinking Abt. Type A ...Decrease Sleep Time by Changing Random
        // Function
      } catch (InterruptedException e) {
      }

      // Need to Increase Student Priority by getPriority() and SetPriority() --still

      msg("Sending Type A Question No. " + i + " by email");
      try {
        Thread.sleep(random());
      } catch (InterruptedException e) {
      }

      // Set Priority to Default -- still

      Teacher.TchrAnsSeq[Teacher.Q_index][0] = Number; // Number: Student Number
      Teacher.TchrAnsSeq[Teacher.Q_index][1] = i; // i: Question number
      Teacher.Q_index++;
    } // for loop ends here
  } // Ask_A function ends here
  public void Think_AskTypeB() { // Increase Student Priority Later....for faster result
    // To ask all B Type questions...Which is equal to "Type_B_Num"

    try {
      p1.mutex.acquire();
    } catch (InterruptedException e) {
    }

    int i = 1;

    while (i <= Type_B_Num) {

      if (QuestionB_Flag == false && Last_QuesB == false) { // Check for M.E....

        msg("Sending via Chatting, (B)Question no. " + i);
        QuestionB_Flag = true; // Must -- Needs M.E. here...
        if (i == Type_B_Num) { // && i!=3
          Last_QuesB = true;
        }
        p1.mutex.release();
        Me_Sleeping(300);
        i++;
      }
    } // While Loop Ends here...
  } // Ask_B function ends here
  public void BrowsingAndWait_UntilOfficeHourEnds() {

    if (Teacher.Onl_Off_HrEnds == false) {
      msg("Browse the Internet Waiting for Online Office Hour to End");
      System.out.println("Alive status:" + this.isAlive());
      Me_Sleeping(10000);
    }
  }
  public void Wait_forLab() throws InterruptedException {
    if (LabOpen == false) {
      msg(" waiting outside the Lab");
    }

    while (LabOpen == false) { // Busy Waiting

      try {
        // Or you can use here Random Time
        Thread.sleep(600);
      } catch (InterruptedException e) {
      }

      if (LabOpen == false) {
        msg(" still waiting outside the Lab");
      }
    }
  } // Function ends here
  public void FinalDescendingCheck() {

    while (true) {
      if (stud[Number + 1].isAlive() == false) {
        msg("Student LEAVES the Lab");
        break;
      }

      Me_Sleeping(100);
    }
  }
 public void Terminate() {
   Me_Sleeping(367 * P1.numOfStudents);
   msg("Will Leave the Lab First");
 }