0

Say a server is capable of handling 8 concurrent connections at a time and it is allowed to have 100 connections to be in the pool the when a thread enters now and it is not allowed to enter into execution thread pool (here it is 8) also there is no space for the thread to be in pool then the thread enters the park WAITING state I guess.

JavaDoc suggests that the thread would be in this park state until

i) A given amount of time. Do we have any default wait time? What happens when we don't configure any amount of time? How long does the thread would be in this wait state?

(or)

ii) Until the permit is available for the thread? Now in this case when the maximum connection limit is set - who does the job of providing permit to wait threads?

  • Your JavaDoc link points to `parkNanos(Object blocker, long nanos)` in which it states `nanos - the maximum number of nanoseconds to wait`. That should answer your first question. – Jonny Henly Jul 13 '17 at 16:50
  • It jus says about the optional param sent via api call. But it doesn't explain much about `park` state of the thread and default values (i.e.' default wait time) of a thread and all.. –  Jul 13 '17 at 17:00
  • The parameter `long nanos` is not an optional parameter, it is present in both `parkNanos(long nanos)` and `parkNanos(Object blocker, long nanos)`. To my knowledge there is no default wait time, the JavaDoc clearly states the situations that can *awaken* a thread. – Jonny Henly Jul 13 '17 at 17:07
  • This is not an optional parameter... What if I don't invoke the api - with set time in milli or nano seconds... –  Jul 13 '17 at 17:11
  • Also what would be the case where the thread in `park` state would be `awakened`? –  Jul 13 '17 at 17:11
  • To your first comment: Sorry, I'm confused when you say *"What if I don't invoke the api - with set time in milli or nano seconds."* What API are you referring too? To your second comment: The method details in the JavaDoc you link to explain the case in which threads in park are awakened. They have a bullet list preceded by *"... and lies dormant until one of [number of bullet list items] things happens:*". They all share multiple reasons, but an idiopathic one in particular being: *"The call spuriously (that is, for no reason) returns."* – Jonny Henly Jul 13 '17 at 17:25
  • @JonnyHenly sorry If I'm confusing.. Let me try to be clear - these thread states in park state is invoked internally and I'm not setting any state value for the thread - it is the underlying operating system which assigns thread a state value - I'm not sure when the operating system assigns weight time and all - and also not sure with the `bulletin points` suggested in the java doc - the thread invoked spuriously - though it's ok to read theoretically - please suggest me some example to understand it clearer... –  Jul 13 '17 at 17:48

0 Answers0