Java 8 Lambda Basics 11 - Runnable Using Lambdas

Java 8 Lambda Basics 11 - Runnable Using Lambdas

Java Brains

7 лет назад

242,047 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@dnyaneshtathode5511
@dnyaneshtathode5511 - 12.05.2022 15:54

Just some small simple info : Runnable would also work as a type to myLambdaThread variable.(Thread works cause Thread class implements Runnable interface).

Ответить
@andysierra5141
@andysierra5141 - 25.04.2022 02:29

what a beautiful video, thanks

Ответить
@Ashrays_melodies
@Ashrays_melodies - 12.04.2022 09:36

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

Ответить
@tanvishinde805
@tanvishinde805 - 20.01.2022 08:45

@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

Ответить
@prishiv1192
@prishiv1192 - 28.09.2021 18:07

public static void main(String args[]) {
Runnable threadRun = () -> System.out.print("Thread Running .... ");
threadRun.run();
}

Ответить
@chetann7411
@chetann7411 - 05.07.2021 07:17

Why new Thread() is needed here? Shouldn't it be
Thread myLamdaThread = () -> sout("something");
instead of
Thread myLamdaThread = new Thread(() -> sout("something"));

Ответить
@kirankumar-vz6jj
@kirankumar-vz6jj - 04.07.2021 20:34

Perfect

Ответить
@yousuf.albums
@yousuf.albums - 08.06.2021 17:57

Thread.start to start off a new thread...
Great explaination nevertheless..!!

Ответить
@sivakrishnat5471
@sivakrishnat5471 - 04.04.2021 18:54

Soothing voice, great explanation.

Ответить
@ravikumarmathanya5369
@ravikumarmathanya5369 - 29.03.2021 16:28

calling myThread.run() won't create any new thread, run() method will be called as normal method

Ответить
@shantanudubey9195
@shantanudubey9195 - 26.11.2020 17:37

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 ?

Ответить
@ron6107
@ron6107 - 05.09.2020 21:52

You are heaven's gift to mankind, love you man!

Ответить
@jvsnyc
@jvsnyc - 13.08.2020 04:18

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.

Ответить
@sanketarekar6400
@sanketarekar6400 - 05.08.2020 15:03

I like the way you traversed from simple interfaces to lambda expressions. This process helps a lot in understanding. You are amazing.

Ответить
@danishkhan2606
@danishkhan2606 - 21.04.2020 18:27

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.

Ответить
@perschistence2651
@perschistence2651 - 19.01.2020 23:47

I would love a tutorial with a deeper look how threads in Java work.

Ответить
@cugoman
@cugoman - 05.01.2020 18:16

you can also write.. new Thread(() -> sout("blah")).start();

Ответить
@earlylikeapp4762
@earlylikeapp4762 - 11.10.2019 18:30

Sir i m from India. Most top and very understandable language u do use. Luv u sir.

Ответить
@abhilash8555
@abhilash8555 - 11.04.2019 13:26

Small correction: Should ideally be .start() though to make it spawn a new thread. Peace.

Ответить
@abhilash8555
@abhilash8555 - 11.04.2019 13:24

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

Ответить
@roronoa_d_law1075
@roronoa_d_law1075 - 11.03.2019 00:54

Awesome !

Ответить
@sindhuja7295
@sindhuja7295 - 21.02.2019 07:51

Your instantiation of Lambda must be for Runnable interface rather than Thread, as per your examples.

Ответить
@samarthurs8000
@samarthurs8000 - 13.01.2019 23:47

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.

Ответить
@arjanmundy
@arjanmundy - 10.11.2018 03:14

Very well planned set of videos.

Ответить
@josephstanton3816
@josephstanton3816 - 08.05.2018 10:56

I'm still trying understand pratical purpose of using lambda functions... the examples you have given just seem more complicated...

Ответить
@KPAdhikari
@KPAdhikari - 26.03.2018 09:01

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.

Ответить
@sunilkhandodiya7671
@sunilkhandodiya7671 - 26.03.2018 06:47

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 ?

Ответить
@deveshgupta2005
@deveshgupta2005 - 25.03.2018 09:11

Call start method in thread in class

Ответить
@seeboonsoo
@seeboonsoo - 20.01.2018 20:25

The best tutorial i ever seen. Good job and thanks so much!

Ответить
@itschethz
@itschethz - 04.12.2017 01:30

I think thread need to call strat() to start a thread instead of run()

Ответить
@rajbharpramod8649
@rajbharpramod8649 - 06.11.2017 11:35

Its nice but Thread must call start method instead of run for starting a new thread .

Ответить
@TheOelsner
@TheOelsner - 07.10.2017 11:26

Gotta say..
Your courses are always top notch :)
Seriously enjoying them all!

Ответить
@jiniamitra7593
@jiniamitra7593 - 08.08.2017 15:31

Ответить
@shalinisingh-uu2kw
@shalinisingh-uu2kw - 17.06.2017 21:12

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?

Ответить
@notyou6264
@notyou6264 - 10.05.2017 00:50

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

Ответить
@TheMahsoon
@TheMahsoon - 01.05.2017 09:56

when you wrote myLambda.run(); where does the word run come from ? what if you remove the myThread declaration .. still myLambda.run(); works ?

Ответить
@upcomingprogrammer6244
@upcomingprogrammer6244 - 02.04.2017 14:10

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 .

Ответить
@duydangdroid
@duydangdroid - 29.03.2017 04:13

Nice series and WOW, nice work by Java

Ответить
@reemiessa2392
@reemiessa2392 - 03.02.2017 18:54

you really made lambda easier to understand for me !
Thank you , Thank you soo much !

Ответить
@hyperborean72
@hyperborean72 - 02.02.2017 22:12

Amazing set of tutorials. Thanks a lot

Ответить
@TheGuroguro12
@TheGuroguro12 - 10.01.2017 15:39

Thank you very much.

Ответить
@gauravgupta1055
@gauravgupta1055 - 18.12.2016 09:21

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

Ответить
@deepakmc8090
@deepakmc8090 - 22.11.2016 19:27

Should be thread.start() ;) On a serious note, I really like the way you have simplified lambda. Very well organised & planned tutorial

Ответить