[]
AutoCloseableCancellationTokenSource allows you to issue cancellation requests to one or more methods.To use a token source: getToken() as parameter.cancel() on this token source.This class is thread safe.
close() method when you don't need to use it anymore.voidcancel()voidcancelAfter(Duration delay) CancellationTokenSource after the specified time span.voidclose()getToken()CancellationTokenSource.It is assumed that the consumers of getToken() will do 'best-effort' attempt to perform cancellation.This method returns immediately and if the cancellation is successful the cancelled operation will throw CancellationException.
CancellationTokenSource after the specified time span.delay - The time span to wait before canceling this CancellationTokenSource. This value can't be null.CancellationTokenSource.close in interface AutoCloseableException