Skip to main content

Posts

Showing posts with the label display vowels program

Write a Java program which will create two child threads by implementing Runnable interface. One thread will print even numbers from 1 to 50 and other display vowels.

Write a Java program which will create two child threads by implementing Runnable interface. One thread will print even numbers from 1 to 50 and other display vowels. Program: import java.io.*; import java.util.*; public class EvenNumberVowel implements Runnable { String name; Thread t; EvenNumberVowel(String str) { name = str; t = new Thread(this, name); t.start(); } public void run() { name = Thread.currentThread().getName(); if(name.equals("First")) { for(int i=1;i<=50;i++){ try { if(i%2==0) { System.out.println("First:"+i); t.sleep(500); } } catch(InterruptedException ie) { System.out.println(ie); } } } else if(name.equals("Second")) { char vowels[] = {'A','E','I...