الدالة المؤقتة Java 42- synchronized method and Multi threading

في هذا الفيديو من جافا JAVA, سنتحدث عن كيفية تشغيل اكثر من عملية واحدة في نفس الوقت, وسنتحدث عن الدالة المؤقتة. synchronized method and Multi threading


package package3;

public class Apple extends Thread{
    @Override
    public void run() {
      for (int index = 0; index < 5; index++) {
        System.out.println("thread "+index);
       }
    }
    
    public void Other(){
      for (int index = 0; index < 5; index++) {
        System.out.println("other "+index);
       }
    }

    public static void main(String... args) {
     Apple app= new Apple();
     app.start();
     app.Other();
    }
}

affiche :
         other 0
         thread 0
         other 1
         thread 1
         other 2
         thread 2
         other 3
         thread 3
         other 4
         thread 4

----------------------------------------------------
package package3;

public class Apple extends Thread{
    @Override
    public void run() {
     Other();
    }
    
    public synchronized static void Other(){
      for (int index = 0; index < 5; index++) {
        System.out.println("other "+index);
       }
    }

    public static void main(String... args) {
     Apple app= new Apple();
     app.start();
     Apple app2= new Apple();
     app2.start();
    }
}

affiche : 
         other 0
         other 1
         other 2
         other 3
         other 4
         other 0
         other 1
         other 2
         other 3
         other 4