In Java 8's java.util.function package, we have:
- Function: Takes one argument, produces one result.
- Consumer: Takes one argument, produces nothing.
- Supplier: Takes no argument, produces one result.
- ...: Other cases handling primitives, 2 arguments, etc...
But I need to handle a "takes no argument, produces nothing" case. There is nothing for this in java.util.functionnal.
Runnable exists, but it is strongly linked to the threading context:
- The package is
java.lang, notjava.util.function. - The javadoc states : "The Runnable interface should be implemented by any class whose instances are intended to be executed by a thread".
- The name "Runnable" suggest some running code inside a thread.
I have already created the functional interface that simply contains a void execute() method declaration, but I don't know how to name the interface.
"Executor" is already taken, I tried "Box", but it doesn't suit me well.
Some ideas?
Aucun commentaire:
Enregistrer un commentaire