Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Can anyone tell me the difference between parked thread and waiting thread in Java? 

1 Answer

0 votes
by (19.7k points)

As per Java Documentation, the park() method has the following usage: 

Disables the current thread for thread scheduling purposes unless the permit is available. If the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:

Some other thread invokes unpark with the current thread as the target; or Some other thread interrupts the current thread; or The call spuriously (that is, for no reason) returns. This method does not report which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread upon return.

To put it in simple terms, a parked thread is a thread that is blocked using LockSupport.park(). For further reference, click here

Interested in Java? Check out this Java tutorial by Intellipaat. 

Related questions

0 votes
1 answer
asked May 11, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
1 answer
asked Mar 8, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
asked Feb 19, 2021 in Java by sheela_singh (9.5k points)

Browse Categories

...