문제

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);
    } 
도움이 되었습니까?

해결책

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.

다른 팁

David is right. But if it's Groovy, you can shorten it to: sleep(1000)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top