-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
questionFurther information is requestedFurther information is requested
Description
주제
- p.80 익명클래스 문제에
Runable뭐하는 녀석일까. - java.lang package에 있음
선정 배경
- 어디서 여러번 본적있는데 뭐하는 역할일까.
본론
- Thread에 의해서 실행되는 클래스 인스턴스의 인터페이스가 Runable 이다.
- 다시말해 Runable은 Thread를 만들고. Thread는 Runable에 있는 run() 메서드로 실행될 수 있다.
The Runnable interface should be implemented by any class whose instances are intended to be executed by a thread. The class must define a method of no arguments called run.
This interface is designed to provide a common protocol for objects that wish to execute code while they are active. For example, Runnable is implemented by class Thread. Being active simply means that a thread has been started and has not yet been stopped.
In addition, Runnable provides the means for a class to be active while not subclassing Thread. A class that implements Runnable can run without subclassing Thread by instantiating a Thread instance and passing itself in as the target. In most cases, the Runnable interface should be used if you are only planning to override the run() method and no other Thread methods. This is important because classes should not be subclassed unless the programmer intends on modifying or enhancing the fundamental behavior of the class.
자바
@FunctionalInterface
public interface Runnable {
/**
* When an object implementing interface <code>Runnable</code> is used
* to create a thread, starting the thread causes the object's
* <code>run</code> method to be called in that separately executing
* thread.
* <p>
* The general contract of the method <code>run</code> is that it may
* take any action whatsoever.
*
* @see java.lang.Thread#run()
*/
public abstract void run();
}sendkite
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested