Repository navigation
Consider using "TimeUnit.<unit>.sleep(x)" for code examples #1518
Copy link
Copy link
Closed
Labels
api: corepriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Activity
Better not to include sleep in the samples, unless we expect users to use it as well. Instead put them in the tests for those samples.
However, if you really most use sleep, then this probably should be preferred.
- addedpriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
on Jun 12, 2017 - addedtype: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
on Nov 9, 2017 The feature request is added to the backlog. The issue will be closed but is linked in the backlog and can continue to be used for comment and discussion.
- added a commit that references this issue
on Jan 22, 2026 - added a commit that references this issue
on Feb 24, 2026 - added a commit that references this issue
on Mar 12, 2026 - added a commit that references this issue
on Mar 23, 2026 - added a commit that references this issue
on Mar 30, 2026 - added a commit that references this issue
on Apr 1, 2026 - added 2 commits that reference this issue
on Apr 29, 2026
Metadata
Metadata
Assignees
Labels
api: corepriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
In most code examples given (both in GitHub & official docs) where a
sleepis needed, thenThread.sleep(x)is used. For example:For better readability/clarity, then it may be prudent to consider using the
TimeUnitclass instead. Yes, it's all the same as it callsThread.sleep(x)under the hood, but consider the following as an example:Thread.sleep(180000)vs.TimeUnit.MINUTES.sleep(3)More info: http://stackoverflow.com/questions/9587673/thread-sleep-vs-timeunit-seconds-sleep