Skip to content

thomas-hugon/async-assignment

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Async Assignment (in Java)

The assignment is about finishing the implementation of the described Async data type — for educational purposes, or for interviewing.

This assignment has been used (with mixed results) for spotting Java developers that could make the transition to Scala and Functional Programming 😎

  1. see Async and Main
  2. read the source code already in place
  3. implement the functions marked with throw UnsupportedOperationException
  4. make sure the tests are passing, see AsyncTest

To run the provided test suite:

$ mvn test

NOTE: the build tool used is Apache Maven.

Details

The described Async data type resembles Java's CompletableFuture, except that it behaves like a function instead of a variable.

Quick usage sample:

import org.alexn.async.Async;
import java.util.Random;
import java.util.concurrent.*;

Async<Integer> number = Async.eval(
  () -> {
    Random rnd = new Random(System.currentTimeMillis());
    return rnd.nextInt();
  });

// Needed for executing tasks
Executor ec = Executors.newCachedThreadPool();

// Actual execution, happens on another thread ;-)
number.run(ec, value -> {
  System.out.println("Generated random number: " + value);
});

About

For educational purposes, or for interviewing Java / Scala developers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%