Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java interface Start/Stop already exist?

Tags:

java

interface

Does an interface with this contract

start();
stop();

Already exist?

I have the impression to recode something classic here...

like image 856
Thomas Avatar asked May 20 '13 12:05

Thomas


People also ask

Do interfaces need Javadoc?

Yes you should write proper Javadoc comments for your interfaces to clearly specific the motivation behind the interface and what the contract is for both callers and implementors.

How many interfaces may a class implement in Java?

But if you really really want to know the theoretical maximum number of interfaces a class can implement, it's 65535.

What should a Java interface contain?

Interfaces in Java In the Java programming language, an interface is a reference type, similar to a class, that can contain only constants, method signatures, default methods, static methods, and nested types. Method bodies exist only for default methods and static methods.


3 Answers

I don't think so, but I'd say even if it does, it'd be much handier to write your own just in case in the future you need to amend it and add a pause(); or similar.

like image 37
david99world Avatar answered Nov 07 '22 19:11

david99world


org.springframework.context.Lifecycle

like image 192
kan Avatar answered Nov 07 '22 19:11

kan


No, at least not without including additional packages, but it's quite easy to create one:

public interface StartAndStoppable { //I am *terrible* at coming up with names :P
    public void start();
    public void stop();
}

This is good because you can also add new methods if needed later.

like image 38
tckmn Avatar answered Nov 07 '22 20:11

tckmn