» נושאי לימוד
» נושאי לימוד
יום שני 29 באפריל 2024
תוכנית לדוגמה
דף ראשי  מתקדמים  Treads of control  סקירה כללית  תוכנית לדוגמה גרסה להדפסה

/*File Thread06.java  Copyright 1997, R.G.Baldwin
Illustrates another way to instantiate and run
threads by extending the Thread class instead of
implementing the Runnable class as was the case in
the program named Thread01.java
Tested using JDK 1.1.3 under Win95.
The output is:
Thread[Thread-1,5,main]
Thread[Thread-2,5,main]
Thread[main,5,main]
**********************************************************/
class Thread06{
static public void main(String[] args){
//Instantiate two new thread objects
Thread myThreadA = new MyThread();
Thread myThreadB = new MyThread();
    //Start them running
myThreadA.start();
myThreadB.start();
    try{//delay for one second
Thread.currentThread().sleep(1000);
}catch(InterruptedException e){}
    //Display info about the main thread
System.out.println(Thread.currentThread());
}//end main()
}//end class Thread06
//=======================================================//
class MyThread extends Thread{
public void run(){
//Display info about this particular thread
System.out.println(Thread.currentThread());
}//end run
}//end class MyThread

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 12-10-03 / 20:48  עודכן ,  12-10-03 / 20:37  נוצר ע"י רונית רייכמן  בתאריך 
 תוכנית Thread - הקודםהבא - פרטים טכניים 
תגובות הקוראים    תגובות  -  0
דרכונט
מהי מערכת הדרכונט?
אינך מחובר, להתחברות:
דוא"ל
ססמא
נושאי לימוד
חיפוש  |  לא פועל
משלנו  |  לא פועל
גולשים מקוונים: 6