I'm using Netbeans 6.9.1 on Ubuntu 10.04 x86 64 to work with Threads in Java. I'm having trouble with the yield() function because when I use it, the current thread continues to run instead of pausing and allowing other threads to execute.

The code below is a simple example copied from here (https://www.scaler.com/topics/yield-method-in-java/) of using yield to run two threads. Instead of running the first thread, printing one line, and then stopping it, the programme finishes thread 1 and then runs thread 2, since the yield method is not invoked. I tested this code on Windows and it works flawlessly! So I'm wondering if there are any issues with using this strategy on Ubuntu or 64bit systems.
public class ThreadTest extends Thread{
    public ThreadTest (String name){
    public void run(){
        for (int i=0;i<5;i++){
            System.out.println(getName()+" - "+i);
        System.out.println(" END "+getName());
public class Main {
   public static void main(String[] args) {
        ThreadTest t1 =new ThreadTest("Thread1");
        ThreadTest t2 =new ThreadTest("Thread2");
Any suggestion, please?