SlideShare a Scribd company logo
JAVA WEEK9(A)
/* Week 9 : a) Write a Java program that creates three threads. First thread
displays “Good Morning” every one second, the second thread displays “Hello” every
two seconds and the third thread displays “Welcome” every three seconds. */



class tst implements Runnable
{
        String name;
        Thread t;
        Arun(String threadname)
        {
           name = threadname;
           t = new Thread(this, name);
          System.out.println("newThread : " +t);
          t.start();
        }
        public void run()
        {
          try
           {
              for(int i=5;i > 0;i--)
                {
                    System.out.println(name + ": " + i);
                     Thread.sleep(1000);
                  }
           }
          catch(InterruptedException e)
           {
             System.out.println(name + "Interrupted");
              }
             System.out.println(name + "exiting");
   }
}
class LabPro16
{
   public static void main(String args[])
     {
        new tst("Good Morning");
        new tst("Hello");
        new tst("Welcome");
        try
        {
           Thread.sleep(10000);
        }
          catch(InterruptedException e)
           {
             System.out.println("Main thread Interrupted");
              }
             System.out.println("Main thread exiting");
   }
}




                                        Page 1

More Related Content

PDF
[Curso Java Basico] Aula 70: Threads: Definindo prioridades
PDF
Porting FreeRTOS on OpenRISC
PDF
Java synchronizers
PDF
エンタープライズ・クラウドと 並列・分散・非同期処理
PDF
The Ring programming language version 1.8 book - Part 9 of 202
PDF
The Ring programming language version 1.9 book - Part 11 of 210
ODP
Clojure made really really simple
PPSX
Control structures
[Curso Java Basico] Aula 70: Threads: Definindo prioridades
Porting FreeRTOS on OpenRISC
Java synchronizers
エンタープライズ・クラウドと 並列・分散・非同期処理
The Ring programming language version 1.8 book - Part 9 of 202
The Ring programming language version 1.9 book - Part 11 of 210
Clojure made really really simple
Control structures

What's hot (20)

PPTX
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
PDF
One Click Ownage Ferruh Mavituna (3)
PDF
Антон Нонко, Классические строки в C++
PDF
Understanding Source Code Differences by Separating Refactoring Effects
PDF
devday2012
PDF
Tcl2012 8.6 Changes
PDF
Terraform: начинайте использовать, если еще не.
PPTX
ECMAScript 2015
PDF
What can be done with Java, but should better be done with Erlang (@pavlobaron)
PDF
Clojure for Java developers - Stockholm
ODP
Clojure made simple - Lightning talk
PDF
The Ring programming language version 1.6 book - Part 77 of 189
PDF
The Ring programming language version 1.6 book - Part 11 of 189
PDF
JAVA NIO
PDF
JavaOne 2013 - Clojure for Java Developers
PPTX
The Art of JVM Profiling
PDF
The Power of CSS
PPT
Python multithreading session 9 - shanmugam
PDF
G*におけるソフトウェアテスト・シーズンIII
PDF
Spock: A Highly Logical Way To Test
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
One Click Ownage Ferruh Mavituna (3)
Антон Нонко, Классические строки в C++
Understanding Source Code Differences by Separating Refactoring Effects
devday2012
Tcl2012 8.6 Changes
Terraform: начинайте использовать, если еще не.
ECMAScript 2015
What can be done with Java, but should better be done with Erlang (@pavlobaron)
Clojure for Java developers - Stockholm
Clojure made simple - Lightning talk
The Ring programming language version 1.6 book - Part 77 of 189
The Ring programming language version 1.6 book - Part 11 of 189
JAVA NIO
JavaOne 2013 - Clojure for Java Developers
The Art of JVM Profiling
The Power of CSS
Python multithreading session 9 - shanmugam
G*におけるソフトウェアテスト・シーズンIII
Spock: A Highly Logical Way To Test
Ad

Similar to Java Week9(A) Notepad (20)

PDF
Advanced Java Practical File
DOC
Inheritance
DOCX
Java practical
PPT
Threadlifecycle.36
PPTX
Java practice programs for beginners
PPTX
Multithreaded programming
PDF
Java programs
PPT
Thread 1
PPTX
14 thread
PPT
final year project center in Coimbatore
PDF
Advanced Java - Practical File
DOCX
Java file
DOCX
Java file
PDF
Simple 27 Java Program on basic java syntax
PPT
Runnable interface.34
PPTX
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
PPT
Java Threads
DOCX
Methods Of Thread Class
ODT
Java practical
DOCX
QA Auotmation Java programs,theory
Advanced Java Practical File
Inheritance
Java practical
Threadlifecycle.36
Java practice programs for beginners
Multithreaded programming
Java programs
Thread 1
14 thread
final year project center in Coimbatore
Advanced Java - Practical File
Java file
Java file
Simple 27 Java Program on basic java syntax
Runnable interface.34
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Java Threads
Methods Of Thread Class
Java practical
QA Auotmation Java programs,theory
Ad

More from Chaitanya Rajkumar Limmala (16)

PDF
Java Week9(B) Notepad
PDF
Java Week6(B) Notepad
PDF
Java Week4(B) Notepad
PDF
Java Week8(A) Notepad
PDF
Java Week3(A) Notepad
PDF
Java Week10 Notepad
PDF
Java Week7 Notepad
PDF
Java Week6(A) Notepad
PDF
Java Week4(A) Notepad
PDF
Java Week4(C) Notepad
PDF
Java Week1(B) Notepad
PDF
Java Week2(C) Notepad
PDF
Java Week2(B) Notepad
PDF
Java Week1(A) Notepad
PDF
Java Week2(A) Notepad
Java Week9(B) Notepad
Java Week6(B) Notepad
Java Week4(B) Notepad
Java Week8(A) Notepad
Java Week3(A) Notepad
Java Week10 Notepad
Java Week7 Notepad
Java Week6(A) Notepad
Java Week4(A) Notepad
Java Week4(C) Notepad
Java Week1(B) Notepad
Java Week2(C) Notepad
Java Week2(B) Notepad
Java Week1(A) Notepad
Java Week2(A) Notepad

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Basic Mud Logging Guide for educational purpose
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharma ospi slides which help in ospi learning
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Module 4: Burden of Disease Tutorial Slides S2 2025
Computing-Curriculum for Schools in Ghana
Microbial diseases, their pathogenesis and prophylaxis
Basic Mud Logging Guide for educational purpose
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O7-L3 Supply Chain Operations - ICLT Program
Cell Structure & Organelles in detailed.
Pharma ospi slides which help in ospi learning
PPH.pptx obstetrics and gynecology in nursing
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Pre independence Education in Inndia.pdf
Insiders guide to clinical Medicine.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Microbial disease of the cardiovascular and lymphatic systems
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
VCE English Exam - Section C Student Revision Booklet
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

Java Week9(A) Notepad

  • 1. JAVA WEEK9(A) /* Week 9 : a) Write a Java program that creates three threads. First thread displays “Good Morning” every one second, the second thread displays “Hello” every two seconds and the third thread displays “Welcome” every three seconds. */ class tst implements Runnable { String name; Thread t; Arun(String threadname) { name = threadname; t = new Thread(this, name); System.out.println("newThread : " +t); t.start(); } public void run() { try { for(int i=5;i > 0;i--) { System.out.println(name + ": " + i); Thread.sleep(1000); } } catch(InterruptedException e) { System.out.println(name + "Interrupted"); } System.out.println(name + "exiting"); } } class LabPro16 { public static void main(String args[]) { new tst("Good Morning"); new tst("Hello"); new tst("Welcome"); try { Thread.sleep(10000); } catch(InterruptedException e) { System.out.println("Main thread Interrupted"); } System.out.println("Main thread exiting"); } } Page 1