promise VS future

时间:2024-03-21 08:05:25

Future and Promise are the two separate sides of an asynchronous operation.

promise is used by the "producer/writer" of the asynchronous operation.

future is used by the "consumer/reader" of the asynchronous operation.

1.

GenericFutureListener.operationComplete(Future) is directly called by an I/O thread. Therefore, performing a time consuming task or a

blocking operation in the handler method can cause an unexpected pause during I/O. If you need to perform a blocking operation on I/O completion,

try to execute the operation in a different thread using a thread pool.