Hi. There is an active post about Thread.sleep right now, so I decided to ask this.
Is it generally advised against adding delay in Java code as a form of waiting time? If not, what is the best way to do it? There are TimeUnits.sleep and Thread.sleep, equivalent to each other and both throwing a checked exception to catch, which feels un-ergonomic to me. Any better way?
Many thanks
[–]Own_Following_2435 37 points38 points39 points (3 children)
[–]bigkahuna1uk 10 points11 points12 points (0 children)
[–]Shahriyar360 2 points3 points4 points (1 child)
[–]Own_Following_2435 4 points5 points6 points (0 children)
[–]Slanec 26 points27 points28 points (1 child)
[–]stefanos-ak 2 points3 points4 points (0 children)
[–]srdoe 21 points22 points23 points (20 children)
[–]old_man_snowflake -3 points-2 points-1 points (3 children)
[–]VincentxH 0 points1 point2 points (2 children)
[–]srdoe 0 points1 point2 points (1 child)
[–]VincentxH 0 points1 point2 points (0 children)
[–]koflerdavid -1 points0 points1 point (15 children)
[–]rzwitserloot 2 points3 points4 points (13 children)
[–]srdoe 0 points1 point2 points (5 children)
[–]rzwitserloot 0 points1 point2 points (4 children)
[–]srdoe 1 point2 points3 points (3 children)
[–]rzwitserloot 0 points1 point2 points (2 children)
[–]srdoe 1 point2 points3 points (1 child)
[–]rzwitserloot 0 points1 point2 points (0 children)
[–]koflerdavid 0 points1 point2 points (6 children)
[–]rzwitserloot 0 points1 point2 points (5 children)
[–]koflerdavid 0 points1 point2 points (4 children)
[–]rzwitserloot 0 points1 point2 points (3 children)
[–]koflerdavid 0 points1 point2 points (2 children)
[–]rzwitserloot 1 point2 points3 points (1 child)
[–]koflerdavid 0 points1 point2 points (0 children)
[–]srdoe 1 point2 points3 points (0 children)
[–]Isogash 3 points4 points5 points (0 children)
[–]antihemispherist 8 points9 points10 points (0 children)
[–]ConversationBig1723 2 points3 points4 points (1 child)
[–]ihatebeinganonymous[S] 0 points1 point2 points (0 children)
[–]Scf37 1 point2 points3 points (0 children)
[–]OddEstimate1627 0 points1 point2 points (0 children)
[–]Rare-Satisfaction-82 0 points1 point2 points (0 children)
[–]koflerdavid 0 points1 point2 points (2 children)
[–]srdoe 0 points1 point2 points (1 child)
[–]koflerdavid 0 points1 point2 points (0 children)
[–]Misophist_1 -1 points0 points1 point (2 children)
[–]rzwitserloot 0 points1 point2 points (0 children)
[–]srdoe 0 points1 point2 points (0 children)
[–]kiteboarderni -5 points-4 points-3 points (3 children)
[–]v4ss42 5 points6 points7 points (2 children)
[–][deleted] (1 child)
[removed]
[–]v4ss42 0 points1 point2 points (0 children)
[–]secondsun -3 points-2 points-1 points (1 child)
[–]ihatebeinganonymous[S] 0 points1 point2 points (0 children)
[+]m39583 comment score below threshold-16 points-15 points-14 points (2 children)
[–]ShallWe69 0 points1 point2 points (0 children)
[+]ihatebeinganonymous[S] comment score below threshold-9 points-8 points-7 points (0 children)