Java callback function

Source: Internet
Author: User

Recently learning Struts2, the filters and interceptors are different, the underlying principle of the filter is based on the callback method, and the interceptor is based on reflection, and then recursion

For the callback function, this blog is very good 51657840

The feeling has a popular explanation:

Using the client and the server as a metaphor, such as client A and Server B,

A to B message, sent, b processing the message to return to a, but it takes a while, and a don't want to, a want to go on doing other things, b processing good news sent over, so need to open a new thread in a,

In this thread A sends a message to B, B receives the message, finishes processing and returns to a, and a can continue to do other things.

In the sense of invoking a method:

There are methods in a SendMessage, call the process method of B, the parameters required to have two, one is to process the message, one is a reference (generally set to a interface, so long as a implementation of this interface can be passed), otherwise b processing the message, do not know to whom Ah, That's right. After the message is processed, B is definitely calling a (the reference to a in the two parameters received by B at this point) to receive the result, and a also gets the result, so that the asynchronous callback is implemented. The Accept method is the callback method.

,,

Java callback function

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.