Notes for system. Exit (0) in asynchronous requests

Source: Internet
Author: User

System. Exit (0) stops all contents in your entire virtual machine, while dispose () Only closes this window, but does not stop the entire application exit (). In any case, the memory is released! That is to say, even if the JVM is disabled, nothing else exists in the memory.
System. Exit (0) is normal exitProgramAnd system. Exit (1) or non-0 indicates that the program exits abnormally.
System. Exit (Status) will exit the program regardless of the value of status. Return is returned to the upper layer, while system. Exit (Status) is returned to the upper layer.

If this method is called immediately after an asynchronous request, it may cause the program to exit before the asynchronous request is complete. This will cause the asynchronous request to fail.

The best solution to this problem:
1) After an asynchronous request, a result is returned, and then exited Based on the returned result;
2) If no result is returned for an asynchronous request, it is best to add a function such as sleep to estimate the time required for the request. This can also be avoided, but it is not the best method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.