34. An example of multi-threading with methods of the life cycle?

class A extends Thread {                 public void run()                 {                                 for(int i=1;i<=5;i++)                                 {                                                 if(i==1)                                                                 yield();                                                 System.out.println("\tFrom Thread A:I = "+i);                                 }                 System.out.println("Exit From A ");                 } } class B extends Thread {                 public void run()                 {                                 for(int j=1;j<=5;j++)                                 {                                                 System.out.println("\tFrom Thread... Continue Reading →

Advertisements

33. For example, of a thread class is as shown below –

class A extends Thread {                 public void run()                 {                                 for(int i=1;i<=5;i++)                                 {                                                 System.out.println("\tFrom Thread A:I "+i);                                 }                 System.out.println("Exit From A ");                 } } class B extends Thread {                 public void run()                 {                                 for(int j=1;j<=5;j++)                                 {                                                 System.out.println("\tFrom Thread B:J "+j);                                 }                ... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: