Thread.sleep(...) doesn't work
Before I dive into details, does for any reason
Thread.sleep(1000)
not work with Railway?
PID: 316b545c-54be-4dbc-a060-bd5b8345755aSolution:Jump to solution
For anyone else, I ended up using WebClient instead of RestTemplate.
I tried sleep, empty loops, ServiceExecutor, waiting on objects in sync blocks - no dice. WebClient solves the issue by taking care of the timing for me....
4 Replies
Project ID:
316b545c-54be-4dbc-a060-bd5b8345755a
I'm making delayed requests to Steam because they don't allow a rate of requests which would theoretically result in over 100k requests in 24 hours.
I've put a
Thread.sleep(1000)
in my API caller and locally it worked just fine. However when deployed it doesn't seem to actually sleep.
So I replaced the sleep call with a ScheduledExecutorService
which delayes the call for 1 second. Worked just fine locally but again does not seem to work when deployed.
Nobody? 😦This is the output with a literally
TimeUnit.SECONDS.sleep(1);
Solution
For anyone else, I ended up using WebClient instead of RestTemplate.
I tried sleep, empty loops, ServiceExecutor, waiting on objects in sync blocks - no dice. WebClient solves the issue by taking care of the timing for me.