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

What's hot (20)

PPTX
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
Sunil Kumar
 
PDF
One Click Ownage Ferruh Mavituna (3)
Ferruh Mavituna
 
PDF
Антон Нонко, Классические строки в C++
Sergey Platonov
 
PDF
Understanding Source Code Differences by Separating Refactoring Effects
Institute of Science Tokyo
 
PDF
devday2012
Juan Lopes
 
PDF
Tcl2012 8.6 Changes
hobbs
 
PDF
Terraform: начинайте использовать, если еще не.
Serhii Vasylenko
 
PPTX
ECMAScript 2015
Sebastian Pederiva
 
PDF
What can be done with Java, but should better be done with Erlang (@pavlobaron)
Pavlo Baron
 
PDF
Clojure for Java developers - Stockholm
Jan Kronquist
 
ODP
Clojure made simple - Lightning talk
John Stevenson
 
PDF
The Ring programming language version 1.6 book - Part 77 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 11 of 189
Mahmoud Samir Fayed
 
PDF
JAVA NIO
오석 한
 
PDF
JavaOne 2013 - Clojure for Java Developers
Jan Kronquist
 
PPTX
The Art of JVM Profiling
Andrei Pangin
 
PDF
The Power of CSS
Aniket Pant
 
PPT
Python multithreading session 9 - shanmugam
Navaneethan Naveen
 
PDF
G*におけるソフトウェアテスト・シーズンIII
Takuma Watabiki
 
PDF
Spock: A Highly Logical Way To Test
Howard Lewis Ship
 
n|u Dharamsala Humla : Memory Forensic by Tenzin Chokden
Sunil Kumar
 
One Click Ownage Ferruh Mavituna (3)
Ferruh Mavituna
 
Антон Нонко, Классические строки в C++
Sergey Platonov
 
Understanding Source Code Differences by Separating Refactoring Effects
Institute of Science Tokyo
 
devday2012
Juan Lopes
 
Tcl2012 8.6 Changes
hobbs
 
Terraform: начинайте использовать, если еще не.
Serhii Vasylenko
 
ECMAScript 2015
Sebastian Pederiva
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
Pavlo Baron
 
Clojure for Java developers - Stockholm
Jan Kronquist
 
Clojure made simple - Lightning talk
John Stevenson
 
The Ring programming language version 1.6 book - Part 77 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 11 of 189
Mahmoud Samir Fayed
 
JAVA NIO
오석 한
 
JavaOne 2013 - Clojure for Java Developers
Jan Kronquist
 
The Art of JVM Profiling
Andrei Pangin
 
The Power of CSS
Aniket Pant
 
Python multithreading session 9 - shanmugam
Navaneethan Naveen
 
G*におけるソフトウェアテスト・シーズンIII
Takuma Watabiki
 
Spock: A Highly Logical Way To Test
Howard Lewis Ship
 

Similar to Java Week9(A) Notepad (20)

PPT
Threadlifecycle.36
myrajendra
 
PDF
Java Thread Synchronization
Benj Del Mundo
 
PDF
Java Multithreading
Ganesh Samarthyam
 
PPT
Java concurrency begining
maksym220889
 
PPS
Java session13
Niit Care
 
PPT
Runnable interface.34
myrajendra
 
PPT
Java multi threading
Raja Sekhar
 
PPTX
Java Multithreading.pptx
RanjithaM32
 
PPT
ThreadProperties
myrajendra
 
PPTX
Java practice programs for beginners
ishan0019
 
PPT
Java Threads
Kapish Joshi
 
PPT
Thread model in java
AmbigaMurugesan
 
PPTX
Java class 6
Edureka!
 
PDF
Threads
saanchi85
 
PPT
Thread 1
RAVI MAURYA
 
PPTX
Java programming PPT. .pptx
creativegamerz00
 
PPTX
OOPS object oriented programming UNIT-4.pptx
Arulmozhivarman8
 
PDF
Advanced Java Practical File
Soumya Behera
 
PDF
Use the Java Thread class to demonstrate the following functionaliti.pdf
arjuntiwari586
 
Threadlifecycle.36
myrajendra
 
Java Thread Synchronization
Benj Del Mundo
 
Java Multithreading
Ganesh Samarthyam
 
Java concurrency begining
maksym220889
 
Java session13
Niit Care
 
Runnable interface.34
myrajendra
 
Java multi threading
Raja Sekhar
 
Java Multithreading.pptx
RanjithaM32
 
ThreadProperties
myrajendra
 
Java practice programs for beginners
ishan0019
 
Java Threads
Kapish Joshi
 
Thread model in java
AmbigaMurugesan
 
Java class 6
Edureka!
 
Threads
saanchi85
 
Thread 1
RAVI MAURYA
 
Java programming PPT. .pptx
creativegamerz00
 
OOPS object oriented programming UNIT-4.pptx
Arulmozhivarman8
 
Advanced Java Practical File
Soumya Behera
 
Use the Java Thread class to demonstrate the following functionaliti.pdf
arjuntiwari586
 
Ad

More from Chaitanya Rajkumar Limmala (16)

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

Recently uploaded (20)

PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PDF
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
DOCX
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
PPTX
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
PDF
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PPTX
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
PPTX
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PPTX
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
PPTX
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
PPTX
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
PPTX
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
PPTX
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Photo chemistry Power Point Presentation
mprpgcwa2024
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 

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