Комментарии:
Just some small simple info : Runnable would also work as a type to myLambdaThread variable.(Thread works cause Thread class implements Runnable interface).
Ответитьwhat a beautiful video, thanks
ОтветитьNothing wrong with run method being used...only thing not right is saying that it spawns a new thread... I always refer back to your videos for lambdas....great explanation
Ответить@JavaBrains I did not get of backward compatibility reason , if the library can accept interface without rewriting , it can accept FunctionType as well, I am assuming library uses Generics in arguments
Ответитьpublic static void main(String args[]) {
Runnable threadRun = () -> System.out.print("Thread Running .... ");
threadRun.run();
}
Why new Thread() is needed here? Shouldn't it be
Thread myLamdaThread = () -> sout("something");
instead of
Thread myLamdaThread = new Thread(() -> sout("something"));
Perfect
ОтветитьThread.start to start off a new thread...
Great explaination nevertheless..!!
Soothing voice, great explanation.
Ответитьcalling myThread.run() won't create any new thread, run() method will be called as normal method
ОтветитьI'm a bit confused here, may be it's something silly but it is bothering me. Why would there be a different function type for the same interface ? For a functional interface, only a single abstract method would be in place and hence would not change the type, right ?
ОтветитьYou are heaven's gift to mankind, love you man!
ОтветитьThe beginning of this video explains very handily why they made the decisions they did about how to handle lambda expressions to fit in with interfaces rather than some exotic new type that didn't fit into the billions of lines of classes and libraries already out there. The comment section in earlier videos shows many people were confused about this or disappointed with it. I hope most of them got at least as far as this video.
ОтветитьI like the way you traversed from simple interfaces to lambda expressions. This process helps a lot in understanding. You are amazing.
ОтветитьThanks for the amazing tutorial on java 8 lambdas.
I am still looking for actual differences between innerclass implementation and a lambda expression.
Please help.
I would love a tutorial with a deeper look how threads in Java work.
Ответитьyou can also write.. new Thread(() -> sout("blah")).start();
ОтветитьSir i m from India. Most top and very understandable language u do use. Luv u sir.
ОтветитьSmall correction: Should ideally be .start() though to make it spawn a new thread. Peace.
ОтветитьWowzies! You are one of the best Java guys out there... It's really interesting the way you perceive concepts in your head and then explain them, It really works for me. awesome clarity of speech as well! Keep up the good work!
eat-code-love,
Abhilash
Awesome !
ОтветитьYour instantiation of Lambda must be for Runnable interface rather than Thread, as per your examples.
ОтветитьThanks a lot for a great tutorial!
Both the statements myThread.run(); and myLamdaThread.run(); will be run by the java "main" thread.
If it was instead myThread.start() and myLamdaThread.start(), then two new threads "Thread-0" and "Thread-1" in addition to the "main" thread would have been created.
Very well planned set of videos.
ОтветитьI'm still trying understand pratical purpose of using lambda functions... the examples you have given just seem more complicated...
ОтветитьEverything was all good (in fact, very impressive to me) except when you used ".run()" instead of ".start()" the threads. Initially I thought may be I have missed something on Java threads, but later I verified making and running my own code that it must be .start() otherwise, the run() method would simply get executed in the current thread ('main' in my case) rather than on a new thread. I hope that was just a type from your part. Other than that I have been really impressed. I couldn't believe that you would make such a simple mistake.
ОтветитьOne question : If library has interface with 2 method then how we can't use lambda expression which makes it is not truly backward compatible. Also Since we are passing argument to call method of interface, shouldn't polymorphosis kick in here and should know which method you are implementing, that will revoke restriction of having only one method in Lambda interace ?
ОтветитьCall start method in thread in class
ОтветитьThe best tutorial i ever seen. Good job and thanks so much!
ОтветитьI think thread need to call strat() to start a thread instead of run()
ОтветитьIts nice but Thread must call start method instead of run for starting a new thread .
ОтветитьGotta say..
Your courses are always top notch :)
Seriously enjoying them all!
wow you exploited Runnable interface contract due to single method but as you mentioned it executes in main Thread and do not create another but if i have to create another Thread ten do i have to follow traditional steps or something interesting is there?
ОтветитьYou are using threads wrong! You are calling the function run() rather than the start() function so it just runs on the normal main thread
Ответитьwhen you wrote myLambda.run(); where does the word run come from ? what if you remove the myThread declaration .. still myLambda.run(); works ?
ОтветитьPlease remove this video and add correct one wehre you use MyThread.start() / MyLambdaThread.start();
Because any one will confused.
I follow your all videos outstanding .
Nice series and WOW, nice work by Java
Ответитьyou really made lambda easier to understand for me !
Thank you , Thank you soo much !
Amazing set of tutorials. Thanks a lot
ОтветитьThank you very much.
ОтветитьI have a query regarding interface. How can we create the lambda expression for those interfaces which is having more than one method. As we know lots of interfaces in java jdk which is having more than one method. If you have any opinion on that please share with us... Thanks Gaurav
ОтветитьShould be thread.start() ;) On a serious note, I really like the way you have simplified lambda. Very well organised & planned tutorial
Ответить