/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Thread thread = new MyThread();
		thread.start();
	}
	
	private static class MyThread extends Thread{
		private final static int runLoopCount = 10;
		private final static long runPeriod = 500;
		public void run(){
			int count = runLoopCount;
			while( count > 0){
				
				//這邊先check something(不會有loop)
				boolean ok = doSomethings();
				
				if( ok){
					return ;
				}
	
				// 準備下一回合
				count--;
				try{
					Thread.sleep(runPeriod);
				} catch(InterruptedException e){
					e.printStackTrace();
				}
			}
		}
		
		private boolean doSomethings(){
			Random random = new Random();
			int ok = random.nextInt(100);
			return (ok%2) == 0;
		}
	}
}


