STIW3054-A191 / Main-Issues

3 stars 2 forks source link

First Thread #3

Open zhamri opened 4 years ago

zhamri commented 4 years ago

Instruction:

Write a Java Program using TWO (2) threads to produce the following output. The output should be display every 1 second.

Example of the output:

1-UP 9--DOWN 2-UP 8--DOWN 3-UP 7-DOWN 4-UP 5-UP 6--DOWN 5--DOWN 6-UP 4--DOWN 7-UP 8-UP 3--DOWN 2--DOWN 9-UP 1--DOWN

Submission:

  1. Your source code
  2. Screenshot the output
sohcheefung commented 4 years ago
//sohcheeefung 259521
class up extends Thread{
    public void run(){
    for(int i=1; i<=9; i++)
        System.out.println(i+"-up");
        try{
            Thread.sleep(1000);
        }catch(Exception e){
         e.printStackTrace();
                    }     
    }          
}
class down extends Thread{
    public void run(){
    for(int i=9; i>=1; i--)
        System.out.println(i+"--down");
        try{
            Thread.sleep(1000);
        }catch(Exception e){
         e.printStackTrace();
                    }
    }
}

public class thread {
    public static void main(String args[]){
        up t1 = new up();
        down t2 = new down();

        t1.start();
        t2.start();

        /*try{
        t1.join();
        }catch(Exception e){    
        }*/
    }
}

java

jasonway96 commented 4 years ago

1.


package Threads;

public class Exercise1 extends Thread
{
    public void run()
    {  
        try 
        {
            for (int x = 1; x < 10; x++) 
            {
                System.out.println(x + "-up");
                sleep(1000);
            }

        } 

        catch (Exception e) 
        {
            e.printStackTrace();
        } 
    }  
}  

class Exercise2 extends Thread
{  
     public void run()
     {  
        try 
            {
                for (int x = 9; x >0; x--) 
                {
                    System.out.println(x + "--Down");
                    sleep(1000);
                }

            } 

            catch (Exception e) 
            {
                e.printStackTrace();
            }
        }  
}  

 class Exercise3
 {  
    public static void main(String args[])
    {  
       Exercise1 t1=new Exercise1();  
       Exercise2 t2=new Exercise2();  

       t1.start();  
       t2.start();  
    }  

}

2. Capture

weiditan commented 4 years ago

Tan Wei Di 259296

package javaapplication32;

class Up extends Thread {

    @Override
    public void run() {
        try {
            for (int x = 1; x < 10; x++) {
                System.out.println(x+"-Up");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class Down extends Thread {

    @Override
    public void run() {
        try {
            for (int x = 9; x > 0; x--) {
                System.out.println(x+"--Down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

public class JavaApplication32  {

    public static void main(String[] args) {
        Up t1 = new Up();
        Down t2 = new Down();
        t1.start();
        t2.start();
    }

}

Untitled

PhuahMeiQi commented 4 years ago

1.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package TestMultitasking;

/**
 *
 * @author MICKY
 */
class Thread1 extends Thread{
    public void run(){
        for(int i=1;i<10;i++){
            System.out.println(i+"-up");
            try{
                Thread.sleep(1000);
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    }
}

class Thread2 extends Thread{
    public void run(){
        for(int i=9;i>0;i--){
        System.out.println(i+"--down");
        try{
                Thread.sleep(1000);
            }catch(Exception e){
                e.printStackTrace();
            }
    }
   }
}

class TestMultitasking {
    public static void main(String args[]){
        Thread1 t1=new Thread1();
        Thread2 t2=new Thread2();

        t1.start();
        t2.start();
    }
}

2. Exercise

aida27 commented 4 years ago

class thread1 extends Thread {

    @Override
    public void run() {
        try {
            for (int x = 1; x < 10; x++) {
                System.out.println(x + " - up");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class thread2 extends Thread {

    @Override
    public void run() {
        try {
            for (int x = 9; x > 0; x--) {
                System.out.println(x + " -- down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

public class run {

    public static void main(String args[]) {
        thread1 t1 = new thread1();
        thread2 t2 = new thread2();

        t1.start();
        t2.start();

    }
}

1

TanChengYi commented 4 years ago

Tan Cheng Yi 253814

  1. Source Code

    
    public class threadTest extends Thread{
    
    public static void main(String[] args) {
        test1 t1 = new test1();
        test2 t2 = new test2();
    
        t1.start();
        t2.start();
    }

}

class test1 extends Thread{ @Override public void run(){ try { for (int x = 1; x < 10; x++) { System.out.println(x+"-UP"); sleep(1000); } } catch (Exception e) { e.printStackTrace(); } } }

class test2 extends Thread{ @Override public void run(){ try { for (int x =9; x>=1; x--) { System.out.println(x+"-DOWN"); sleep(1000); } } catch (Exception e) { e.printStackTrace(); } } }


2. Output
![image](https://user-images.githubusercontent.com/46247836/65096290-02e19b00-d9f7-11e9-8462-74938d5ae912.png)
SilentHlive commented 4 years ago

public class exercise {

    public static void main(String[] args) {
        exercise1 t1 = new exercise1();
        exercise2 t2 = new exercise2();

        t1.start();
        t2.start();
    }
}

    class exercise1 extends Thread {
        public void run() {
        try {
            for (int x = 1; x < 10; x++) {
            System.out.println(x + "-Up");
            sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

    class exercise2 extends Thread{
        public void run() {
        try {
            for (int y = 9; y > 0; y--) {
            System.out.println(y +"--Down");
            sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

output

macasyraf commented 4 years ago

public class mainPlug
{
    public static void main(String[] args)
    {
        new threadPlug().start();
        new countPlug().start();
    }
}

public class threadPlug extends Thread
{
    public void run()
    {
        for (int i = 1; i < 10; i++)
        {
            System.out.println(i + "-UP");
        }

        try
        {
            Thread.sleep(1000);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }
}

public class countPlug extends Thread
{
    public void run()
    {
        for (int i = 9; i > 0; i--)
        {
            System.out.println(i + "--DOWN");
        }

        try
        {
            Thread.sleep(1000);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }
}

image

coNNectGan commented 4 years ago

GAN LIAN JIE (255108)

class Thread1 extends Thread {

    public void run() {
        try {
            for (int x = 1; x < 10; x++) {
                System.out.println(x + "-up");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class Thread2 extends Thread {

    public void run() {
        try {
            for (int x = 9; x > 0; x--) {
                System.out.println(x + "--Down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class MultipleThreads {

    public static void main(String args[]) {
        Thread1 t1 = new Thread1();
        Thread2 t2 = new Thread2();

        t1.start();
        t2.start();
    }

}

Capture11

OXunSheng commented 4 years ago

Ong Xun Sheng 253881

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package multithread;

/**
 *
 * @author Xun Sheng
 */

class thread1 extends Thread{
  public void run(){
    try{
      for(int i = 1; i<=9 ; i++){
      System.out.println(i + "-UP");
        Thread.sleep(1000);
    }
    }
    catch(Exception e){
      e.printStackTrace();
    }

  }
}
class thread2 extends Thread{
  public void run(){
    try{
      for(int i = 9; i>0 ; i--){
      System.out.println(i + "--DOWN");
        Thread.sleep(1000);
    }
    }
    catch(Exception e){
      e.printStackTrace();
    }

  }
}

public class MultiThread {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        thread1 t1 = new thread1();
        thread2 t2 = new thread2();
        t1.start();
        t2.start();
    }

}

asf

yeongshyhhaw commented 4 years ago

/*

import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger;

/*

} class thread1 extends Thread{ public void run(){

   for(int i=1; i<=9; i++){  

       System.out.println(i+"-up");
      try {
          Thread.sleep(1000);
      } catch (InterruptedException ex) {
          Logger.getLogger(thread1.class.getName()).log(Level.SEVERE, null, ex);
      }

                         }     
               }          

} class thread2 extends Thread{ public void run(){

for(int i=9; i>=1; i--){

    System.out.println(i+"--down");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException ex) {
        Logger.getLogger(thread2.class.getName()).log(Level.SEVERE, null, ex);
    }
}
}

} Capture

thineshsubramani commented 4 years ago
class Up extends Thread {
    public void run(){
     try{   for (int i = 1;i<10;i++){
        System.out.println(i + "-up");
      Thread.sleep(900);
    }}catch(Exception e){
        e.printStackTrace();
    }
}
}
class Down extends Thread {
    public void run(){

  try{  for (int i = 9;i>0;i--){
        System.out.println(i+ "--down");
        Thread.sleep(1000);
    }} catch (Exception e){
        e.printStackTrace();
    }
}
}

public class myThread{

    public static void main(String[] args) {

     Up t1 = new Up();
     Down t2 = new Down();
     t1.start();
     t2.start();

    }

} 

Screenshot_3

Zulaikha97 commented 4 years ago

package STIW3054;

/**
 *
 * @author master lab
 */
public class Up extends Thread {

    @Override
    public void run() {
        try {
            for (int x = 1; x < 10; x++) {
                System.out.println(x + "-up");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

package STIW3054;

/**
 *
 * @author master lab
 */
class Down extends Thread {

    @Override
    public void run() {
            try {
                for (int x = 9; x > 0; x--) {
                System.out.println(x + "--down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

package STIW3054;

/**
 *
 * @author master lab
 */
class Result {

    public static void main(String args[]) {
        Up t1 = new Up();
        Down t2 = new Down();

        t1.start();
        t2.start();
    }

}

image

najihahF commented 4 years ago

public class threadIssue{

    public static void main(String args []) {
        issue1 t1 = new issue1();
        issue2 t2 = new issue2();

        t1.start();
        t2.start();
    }

}

class issue1 extends Thread{
    @Override
    public void run(){
        try {
            for (int i = 1; i < 10; i++) {
                System.out.println(i+"- Up");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class issue2 extends Thread{
    @Override
    public void run(){
        try {
            for (int i =9; i>=1; i--) {
                System.out.println(i+"- Down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

issue_1

vissanuck commented 4 years ago
public class ExerciseRt extends Thread {

        public static void main (String args[]){
            new ThreadUp().start();
            new ThreadDown().start();
        }
    }

public class ThreadUp extends Thread {
    public void run() {
        for (int i = 1; i < 10; i++) {
            System.out.println(i + "-UP");
        }
        try
        {
            Thread.sleep(1000);
        }catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }
}

public class ThreadDown extends Thread {
    public void run() {
        for (int i = 9; i > 0; i--) {
            System.out.println(i + "--DOWN");
        }
        try
        {
            Thread.sleep(1000);
        }catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }
}

image

sonyhana7 commented 4 years ago

First Thread

public class Exercise1 extends Thread{

    @Override
    public void run() {

      try{
        for (int x = 1; x <=9; x++) {
            System.out.println(x + "-up");
            sleep(1000);

        }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

**Second Thread**

public class MyThread extends Thread {

    public void run(){
     try{
         for (int x=9; x>=1; x--){
             System.out.println(x+"---down");
              sleep(1000);
         }

        }catch(Exception e){
            e.printStackTrace();
        }

    }
}

**Third Thread**

public class MyThreadThread {

    public static void main ( String [] args){

        Exercise1 t1 = new Exercise1();
        MyThread  t2 = new MyThread();

        t1.start();
        t2.start();
}
}

image

Gv3N commented 4 years ago

public class RTMain extends Thread {
    public static void main(String [] args){
        Thread1 T1 = new Thread1();
        Thread2 T2 = new Thread2();
        T1.start();
        T2.start();

    }//main
}//RTmain

public class Thread1 extends Thread{
        public void run() {
            try {
                for (int x = 1; x < 10; x++) {
                    System.out.println(x + "-up");
                    sleep(1000);
                }//for
            } catch (Exception e) {
                e.printStackTrace();
            }//catch
        }// run
    }//Thread1

public class Thread2 extends  Thread {
    public void run() {
        try {
            for (int x = 9; x > 0; x--) {
                System.out.println(x + "--down");
                sleep(1000);
            }//for
        } catch (Exception e) {
            e.printStackTrace();
        }//catch
    }//run
}//Thread2

ss thread

WwLuo-1024 commented 4 years ago
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package first;

/**
 *
 * @author master lab
 */
public class First extends Thread
{
    public void run()
    {  
        try 
        {
            for (int x = 1; x < 10; x++) 
            {
                System.out.println(x + "-up");
                sleep(1000);
            }

        } 

        catch (Exception e) 
        {
            e.printStackTrace();
        } 
    }  
}  

class Last extends Thread
{  
     public void run()
     {  
        try 
            {
                for (int x = 9; x >0; x--) 
                {
                    System.out.println(x + "--Down");
                    sleep(1000);
                }

            } 

            catch (Exception e) 
            {
                e.printStackTrace();
            }
        }  
}  
public class FirstApp {
    public static void main(String[] args){
        First fir = new First();
        Last las = new Last();

        fir.start();
        las.start();
}
}

65095637-9f566e00-d9f4-11e9-9dfa-7966c92e9725

liviniesh commented 4 years ago
package s;

class thread1 extends Thread{
      @Override
    public void run(){
    for(int x=1; x<=9; x++)

        try{
            System.out.println(x+"-up");
            Thread.sleep(1000);
        }catch(Exception e){
         e.printStackTrace();
                    }     
    }          
}
class thread2 extends Thread{
   @Override
    public void run(){
    for(int x=9; x>=1; x--)

        try{
          System.out.println(x+"--down");
            Thread.sleep(1000);
        }catch(Exception e){
         e.printStackTrace();
                    }
    }}
  class MyThread {
  public static void main(String args[])
    {  
       thread1 t1=new thread1();  
       thread2 t2=new thread2();  

       t1.start();  
       t2.start();  
    }  }

Capture

ychian234 commented 4 years ago

public class test  {
    public static void main(String[] args) {
        Test1 t1 = new Test1();
        Test2 t2= new Test2();
        t1.start();
        t2.start();
    }
}
class Test2 extends Thread {
    public void run() {
        try {
            for (int x = 9; x > 0; x--) {
                System.out.println(x+"--Down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
class Test1 extends Thread {
    @Override
    public void run() {
        try {
            for (int x = 1; x < 10; x++) {
                System.out.println(x+"-Up");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Capture

peipei28 commented 4 years ago

package Threads;

import java.util.logging.Level; import java.util.logging.Logger;

public class test2 extends Thread {

public static void main(String[] args) {

  up t1 = new up();
  down t2 = new down();

  t1.start();
  t2.start();
}

}

class up extends Thread { public void run (){

    for (int x=1; x<10 ; x++ )
    {
      System.out.println(x+"-up");
        try {
            sleep(1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(up.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}  
}

class down extends Thread { public void run (){

    for(int i=9; i>=1; i--){
    {
      System.out.println(i+"--down");
        try {
            sleep(1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(down.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}  
}

exe

chinsfuh commented 4 years ago
package stiwThread;
class Thread0 extends Thread {

    @Override
    public void run() {
        try {
            for (int x = 1; x < 10; x++) {
                System.out.println(x+"-Up");
                sleep(800);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

----------------------------------------------------------------------

package stiwThread;
class Thread1 extends Thread {

    @Override
    public void run() {
        try {
            for (int x = 9; x > 0; x--) {
                System.out.println(x+"--Down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

-------------------------------------------------------------

package stiwThread;
public class Output  {

    public static void main(String[] args) {
        Thread0 t1 = new Thread0();
        Thread1 t2 = new Thread1();
        t1.start();
        t2.start();
    }

}

image

sufyankamal commented 4 years ago

class Thread1 extends Thread {

@Override
public void run() {
    try {
        for (int x=1;x<10;x++) {
            System.out.println(x+"-Up");
            sleep(800);
        }
    } catch (InterruptedException e) {
    }
}

} class Thread2 extends Thread { @Override public void run() { try { for (int x=9;x>0;x--) { System.out.println(x+"--Down"); sleep(1000); } } catch (InterruptedException e) { } } }

public class NewClass { public static void main(String[] args) { Thread1 t1 = new Thread1(); Thread2 t2= new Thread2(); t1.start(); t2.start(); }

}

Capture

yyjmax commented 4 years ago
package test;

public class UpDown extends Thread {

  public void run() {

    for(int i = 1;i<10;i++){
      try{
      System.out.println(i+"-up");
      sleep(1000);
      }
      catch(Exception e){
        e.printStackTrace();
      }
    }

  }
}

class Down extends Thread {
 public void run() {

   for(int i = 9;i>0;i--){
     try{
      System.out.println(i+"--down");
      sleep(1000);
    }
   catch(Exception e){
        e.printStackTrace();
      }
   }

  }
}

package test;

class testtest {
  public static void main(String[] args) {
    UpDown u = new UpDown();
    Down d = new Down();

    u.start();
    d.start();
    }
}

image

Nurshafiqahdiela commented 4 years ago
class thread0 extends Thread {

    public void run(){

        try {
            for (int x = 1; x < 10; x++) {
                System.out.println(x + "-up");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
class thread2 extends Thread{
    public void run(){

        try {
            for (int x = 9; x >0; x--) {
                System.out.println(x + "--Down");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
public class Thread1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        thread0 t1 = new thread0();
        thread2 t2 = new thread2 ();

        t1.start();
        t2.start();   
    }

}

Exrcse 1 RealTime

fazlizam96 commented 4 years ago
class JavaTest1 extends Thread {
    @Override
    public void run() {
        try {
            for(int x=1; x<10; x++) {
                System.out.println(x + "-UP");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class JavaTest2 extends Thread {
    @Override
    public void run() {
        try {
            for(int x=9; x>0; x--) {
                System.out.println(x + "--DOWN");
                sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

public class Javatest extends Thread{
    public static void main(String args[])
    {
        JavaTest1 t1= new JavaTest1();
        JavaTest2 t2= new JavaTest2();

        t1.start();
        t2.start();
    }
}

test1

farisleh commented 4 years ago
MyClass.java File

class MyClass extends Thread {

    public static void main(String args[]) {
        up t1 = new up();
        down t2 = new down();

        t1.start();
        t2.start();

    }

}

up.java File

public class up extends Thread {
    public void run() {
    try {
        for (int x = 1; x < 10; x++) {
            System.out.println(x +"-Up");
            sleep(1000);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

}

down.java File

public class down extends Thread {
    public void run() {

    try {
        for (int x = 9; x >= 1; x--) {
            System.out.println(x +"--Down");
            sleep(1000);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}}

Output sss

muhdhariz commented 4 years ago
Assignment file
public class Assignment1{
    public static Thread1 t1 = new Thread1();
    public static Thread2 t2 = new Thread2();
    public static void main(String[] args) {
        t1.start();
        t2.start();
    }
}
Thread1 file
public class Thread1 extends  Thread{
    public void run() {
        try {
        for (int z = 1; z <= 9; z++) {
            System.out.println(z + "-UP");
                Thread.sleep(1000);
        }
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}
Thread2 file
public class Thread2 extends Thread{
    public void run() {
        try {
        for (int z = 9; z >= 1; z--) {
            System.out.println(z + "--Down");
                Thread.sleep(1000);
        }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

image

aidqayyum commented 4 years ago
import static java.lang.Thread.sleep;

class first_thread {
    public static void main(String[] args){
        threads1 t1 = new threads1();
        threads2 t2 = new threads2();

        t1.start();
        t2.start();
    }
}

class threads1 extends  Thread{
    public void run(){
        try{
            for (int x = 1; x < 10; x++){
                System.out.println(x + "-UP");
                sleep(1000);
            }
        } catch (Exception e){
            e.printStackTrace();
        }

    }
}

class threads2 extends Thread{
    public void run(){
        try {
            for (int x =9; x > 0; x--){
                System.out.println(x + "-Down");
                sleep(1000);
            }
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}

output intellij

AhmedBawazir2020 commented 4 years ago

package issues3;

import static java.lang.Thread.sleep;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ahmed_Bawazir
 */
public class Issues3 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)  {

        Mythread a= new Mythread();
        Mythread2 b = new Mythread2();
        a.start();
        b.start();

    }

}
class Mythread extends Thread{
   public void run(){
       for(int i=1 ;i<=9;i++){
           try {
               System.out.println(i+"-up");
               sleep(1000);
           } catch (InterruptedException ex) {
               Logger.getLogger(Mythread.class.getName()).log(Level.SEVERE, null, ex);
           }
       }
    }
}  

class Mythread2 extends Thread{
    public void run(){
        for(int i=9;i>=1;i--){
            System.out.println(i+"--Dwne");
            try {
                sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(Mythread2.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }
}
AhmedBawazir2020 commented 4 years ago

Capture

FatihahFauzi commented 4 years ago
class up extends Thread{
    public void run(){
        for(int i=1; i<=9; i++)
            System.out.println(i+"-up");
        try{
            Thread.sleep(1000);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
class down extends Thread{
    public void run(){
        for(int i=9; i>=1; i--)
            System.out.println(i+"--down");
        try{
            Thread.sleep(1000);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}

public class FirstThread {
    public static void main(String args[]){
        up t1 = new up();
        down t2 = new down();

        t1.start();
        t2.start();

           }
}

image