Вопрос

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