Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package trythread;
-
- /**
- *
- * @author Dee
- */
- public class TryThread {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Kopassus kop = new Kopassus();
- kop.start();
- }
- }
- class Kopassus extends Thread {
- @Override
- public void run() {
- System.out.println("First Mission Started");
- System.out.println("------------------------------------");
- System.out.println(" Kopassus entering the battlefield. ");
- System.out.println(" Kopassus begin evacuate the victim. ");
- System.out.println("------------------------------------");
- for (int i = 1; i <= 20; i++) {
- try {
- sleep(200);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- if (i < 20) {
- System.out.println(i + " pregnant women has been evacuated");
- } else if (i == 20) {
- System.out.println(i + " pregnant women has been evacuated");
- System.out.println("-------------------------------");
- Marine marine = new Marine();
- marine.start();
- }
- }
- }
- }
- class Marine extends Thread {
- @Override
- public void run() {
- System.out.println("Second Mission Started.");
- System.out.println("Marine Entering Battlefield.");
- System.out.println("-------------------------------");
- for (int a = 1; a <= 50; a++) {
- try {
- sleep(100);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- System.out.println("Marine has been kill " + a + " terorist");
- if (a <= 20) {
- System.out.println(a + " elderly has been evacuated");
- if (a == 20) {
- System.out.println(" First Mission Completed.");
- System.out.println("-------------------------------");
- }
- }
- if (a == 50) {
- System.out.println("Second Mission Complete.");
- System.out.println("---------------------------.");
- System.out.println("Third Mission Started.");
- System.out.println("Infantry Start Cleaning.");
- System.out.println("Third Mission Completed.");
- System.out.println("--------------------------");
- System.out.println("All Mission Completed.");
- // flag1 = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement