-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
None
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
As a student/new learner/experienced programmer etc., I have to use some common code to create Thread and start it from Runnable functional interface lambda implementation.
Eg: Runnable test = () -> System.out.println("My Runnable Task");
Thread t1 = new Thread(test);
t1.start();
Could we create default method and its overloaded versions in Runnable interface to move above mentioned last two lines of code to Runnable interface?
Eg: default Thread startThread() {
Thread t = new Thread(this);
t.start();
return t;
}
Then I can create a single/multiple threads using startThread() function on Runnable interface lambda object directly.
It could be a better option to merge Runnable and Thread APIs into one FunctionalInterface creating simplicity for new developers.
I am happy to discuss further on it and can contribute to openjdk if required once approved.
As a student/new learner/experienced programmer etc., I have to use some common code to create Thread and start it from Runnable functional interface lambda implementation.
Eg: Runnable test = () -> System.out.println("My Runnable Task");
Thread t1 = new Thread(test);
t1.start();
Could we create default method and its overloaded versions in Runnable interface to move above mentioned last two lines of code to Runnable interface?
Eg: default Thread startThread() {
Thread t = new Thread(this);
t.start();
return t;
}
Then I can create a single/multiple threads using startThread() function on Runnable interface lambda object directly.
It could be a better option to merge Runnable and Thread APIs into one FunctionalInterface creating simplicity for new developers.
I am happy to discuss further on it and can contribute to openjdk if required once approved.