in C# , Task
class has ContinueWith
method, when the task runs to complete status, the ContinueWith
method will be invoked, and in JAVA, is there some methods like ContinueWith
?
I know the guava listenablefuture
, but it use a new thread to wait the 'task' to complete, is it equal to C# ContinueWith
?
and JAVA 8 CompletableFuture
whenComplete
has the same effect, so what's the difference in C# ContinueWith
listenablefuture
CompletableFuture
?
thank you!
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
C is more difficult to learn than JavaScript, but it's a valuable skill to have because most programming languages are actually implemented in C. This is because C is a “machine-level” language. So learning it will teach you how a computer works and will actually make learning new languages in the future easier.
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
A Task
in .Net and a CompletableFuture
in Java accomplish a very similar purpose. They provide a reference to something that is executing in a different thread (a TaskScheduler
in .Net or an Executor
in Java), with the ability to wait for the result and/or perform different actions on completion.
There are a couple of differences between Task.ContinueWith
and CompletableFuture.whenComplete
. For one, the function passed into the .Net version takes the Task
itself as an argument, requiring an additional step to get its result (or to propagate downstream exceptions if necessary). The function passed into Java version takes the result of the task as an argument.
The other significant difference is the thread on which the continuation task will run. In .Net, it will by default run on a different thread from the main task. In Java, it will by default run on the same thread as the main task. These default actions can be overridden in both cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With