Code Here: http://goo.gl/qNik3
Best Java Book : http://goo.gl/FtKp0m
In this Java Video Tutorial I cover how to use Java threads.
A thread is just a block of code that is expected to execute while other blocks of code execute. That’s it. When you want to execute more than one block of code at a time you have to alert Java.
Amazon Auto Links: No products found.
its funny how “String” and “thread” in reality are types of unwoven fabric or cloth
do you know how to calculate the difference of two dates?
why my same code is giving error saying – Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – constructor getTheMail in class getTheMail cannot be applied to given types;
required: no arguments
found: int
reason: actual and formal argument lists differ in length
at mainTime.main(mainTime.java:6)
C:UsersuserAppDataLocalNetBeansCache8.2executor-snippetsrun.xml:53: Java returned: 1
BUILD FAILED (total time: 6 seconds)
You should lock System.out for only 1 thread to use at a time.
Hey Derek. I’m from Bangladesh. From the beginning of my Java Course in my University I follow your videos. You are the reason of my good marks in Java till now. I never thought my country would be mentioned here. It felt good. Thanks for the awesome videos. 🙂
yesterday understand less than 50%
today understand everything…
Cool! 😀
Where is the runnable interface?
7:00 getThemMail XD
The thing I love about your videos is they aren’t intimidating. Even if I don’t know something, I’m not scared away by it because you explain it so well. Keep up the great work! Glad to finally get an understanding of threads.
// You can use the Runnable interface instead of
// wasting your 1 class extension.
i dont get it . Why did you use Runnable ? it is thread or interface ?
Thank you
You saved my head from getting blasted. Your tutorial helped me to get the use of thread.
wouldn’t that be great if you plan a day in a week or so to answer doubts real time.. only if it’s comfotable for you.. pls
Wanted to say thanks for your videos Derek, I finally have my first skills interview tomorrow for an entry level java position, and your videos have helped a bunch.
+Derek Banas gr8 tutorials on java!!!!!! Awesome way of teaching,,keep up the good work sir..!! 🙂
I’m din’ your series from this tutorial as I already new much. But now when I see the upcoming topics of your series , I just can’t wait. You’ve made the topics awesome. thank you.
Derek, do you have a video on iterator implementation in Java?
I find we need this cord.
Thread getMailThread = new Thread(getmail);
getMailThread.start();
But, you just used this.
new Thread(getMail).start();
how come you can use that one? I don’t get one.
Why we call object like this: Thread name = new Thread1(); and not like: Thread1 name = new Thread1();
Hey Derek i have a quick question. In OOP language when creating a object/ instance you have to declare in this fashion
C++ (Class) (object name) (constructor); in Java (Class) (object name) = new (Class) (constructor);. in the case of the DateFormat
you created 2 instances timeFormatter & dateFormatter but did not use the syntax stated above. instead it uses a (Class)(Method)(args)
syntax. i have look around on the oracle website but no explanation as to why it is created this way can out elaborate on why it uses a
different syntax thanks 😀
3:00:05 AM
Jan 1, 1970 ……….. oh wow my PC is so old LOL
Hey Derek! Can you please recommend a good book for practicing Java .I feel learning java will only be half complete ,if I don’t practice these OOP concepts.
OMG thank you so much for video. You saved my ass for college 😀
May I ask what the 2 threads exactly are? Are they “Date” and “Time”? Just making sure.
What is the difference between a class that implements runnable and a class that extends the thread class? Is there a benefit of using one or the other to create a thread?
Do we need to explicitly define the default constructor or Java does it automatically?
At some places I found we need to define those but in here we didn’t define the default constructor GetTime20(). Am I missing something?
this code does NOT check the mail every 10 seconds, it checks only once after 10 seconds for “getMail” and after 20 seconds for getMailAgain.
For 20 iterations with a sleep of 2 secs it should output “Checking mail” at least 4 times and when I test it it outputs “Checking mail” only twice.
Why is that?
why the same code in my ide is giving me errors?
Your videos are awesome though!!
dude you have the potential to post ‘A’ quality tutorials but you’re limiting yourself to ‘B’ because you dont take the time to talk about the theory and thought processes. Telling someone how to type a thread is easy but its when you teach someone how to KNOW how to build threads is what the students need. It just makes it so much more difficult to learn.
What needs to happen is you to go more in depth. think about your wordings more.
so what is object class
how do i do to remember all this stuff? is there any tricks for memorizing?
thanks. very good tutorial
So a thread runs infinite times until we stop it right?
Dude. Awesome stuff. I am subscriber now.
If I have several threads running and I want to run a command based on the last one that finishes. How do I check for that. Is there a thread ends type event I can run an if statement against?
It’s not printing “Checking Mail” for me. Any ideas?
Here is my GetTheMail class: http://pastebin.com/9kHpJ5ah
My GetTime20 class: http://pastebin.com/dTAGCFVv
and my JavaLessonSeventeen class: http://pastebin.com/H0g5dPhv
Can you use GetTheMail class to extend the thread class, instead of implementing the Runnable interface?
Sir! how to avoid execution of finally block….?? please tell me any three methods to do so….
Hi Derek, lots of the time I watch the videos on my iPad mini and I can’t right down the code cause someone else is using the computer! Some things I do not get probably cause I am only 12 years old! Do you know a way or practice that can help me better understand??
Hey, I’d like to ask you to help me … I’m facing a problem with the methods , it’s hard to memorize this number of methods in java .. thank you
why did you write Runnable?
Why does the GetTheMail thread stop when the GetTheTime thread stops? We didn’t use a for-loop in the GetTheMail thread, yet it stopped executing when GetTheTime stopped.
I was kinda imagining of my country Bangladesh when you were stating the different languages . Felt epic when you said that .
As always , you made an epic video
It felt so great when u said the name “Bangladesh”.
I hope within 30 years i’ll be as cool as u 😉
Such an awesome guy you are.Respect from Bangladesh!
What is ‘Runnable getMail = new GetTheMail(10);’?
Is it same as ‘GetTheMail getMail = new GetTheMail(10);’?
How can I get output that is not a String, Integer or stuff like that but something like a green circle or maybe a more complex shape? Do I need another program or can I maybe just modify the “System.out.” command?
Hello Derek 🙂 I have a question.. The constructor of the thread class only accepts objects of classes that have implemented the runnable interface.. How can we do something similar with our classes?? I mean like having an interface implementation as a must…
Thank you!
Dear Derek this was hard to understand as you did’nt explain what threads are and other underlying details.
I found that you can display input while entering in an input in the console using threading O.O
Why do you not use the GetTime20 getTime = new GetTime20(); instead of using the Thread getTime = new GetTime20();?