You could just cause the thread to sleep with Thread.sleep(1000);
but this would stop the entire back end application (if it was single threaded), so it would work if your waiting screen was client side javascript, not if it was fired from the server side.
How do I throttle or slow down Grails?
-
17-01-2022 - |
题
I'm testing an AJAX application, and I need to test my loading/wait screens. I'd like to make the application take a longer time to respond to an AJAX request. The following code works okay, but is rather inelegant. Perhaps a thread or a timer?
int i = 0
double j
for (i = 0; i < 1000000; i++) {
j = Math.sin(j);
}
解决方案
其他提示
David is right. But if it's Groovy, you can shorten it to: sleep(1000)
不隶属于 StackOverflow