Pregunta

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);
    } 
¿Fue útil?

Solución

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.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top