Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like C# Task in Java?

I am trying to learn C#! I am most familiar with Java between programming languages! Just now I am trying to understand Task's! Is there something like Task in Java?

What are the differences between Task's and threads? What does Task offer that threads can not do? Basically why do we need Task's?

like image 650
Govan Avatar asked Aug 18 '12 11:08

Govan


People also ask

Is there an alternative to C?

The best alternative is Java. It's not free, so if you're looking for a free alternative, you could try C++ or Rust. Other great apps like C (programming language) are Go (Programming Language), C#, Lua and Perl.

Does C still exist?

The C programming language has been alive and kicking since 1972, and it still reigns as one of the fundamental building blocks of our software-studded world.

Is there something faster than C?

This is why Fortran is often faster than C. This is why numerical libraries are still written in Fortran. However, it comes at the cost of pointer arithmetic.

What languages are similar to C?

Many of the more popular C-style languages are object-oriented (C++, Java, C#), but C itself is not. Many of the other big names, such as Python, Perl, PHP, and Ruby also have a C-style influence, although how important that is, and to what degree, depends on who you ask.


2 Answers

I'd say the closest 1:1 class is Future<T> or CompletableFuture<T>. CompletableFuture has some extra chaining methods similar to those in Task<T> in C#.

Apparently in early versions of the Task Parallel Library (C#) Task<T> was called Future<T> (http://www.nedstoyanov.com/promises-and-futures/)

like image 115
Mingwei Samuel Avatar answered Oct 17 '22 04:10

Mingwei Samuel


The Fork/Join framework introduced in Java 7 is probably the closest thing:

http://docs.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html

like image 5
Dan Avatar answered Oct 17 '22 05:10

Dan