1.

We Should Implement Runnable Interface Or Extend Thread Class. What Are Differences Between . How Can You Say Thread Behaviour Is Unpredictable?

Answer»

Thread behaviour is unpredictable because execution of Threads DEPENDS on Thread scheduler, thread scheduler may have different implementation on different platforms like windows, unix etc. Same threading program may produce different OUTPUT in subsequent executions even on same platform.
To achieve we are GOING to create 2 threads on same Runnable Object, create for LOOP in run() method and start both threads. There is no surety that which threads will complete first, both threads will enter anonymously in for loop.

 

Thread behaviour is unpredictable because execution of Threads depends on Thread scheduler, thread scheduler may have different implementation on different platforms like windows, unix etc. Same threading program may produce different output in subsequent executions even on same platform.
To achieve we are going to create 2 threads on same Runnable Object, create for loop in run() method and start both threads. There is no surety that which threads will complete first, both threads will enter anonymously in for loop.

 



Discussion

No Comment Found