Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
Threads in Java
I’m having trouble understanding threads in Java, can someone explain what is it and when is it used?
3 ответов
+ 6
first you learn what is draw back of thread....why we we use thread...
in previous we use sequential flow of execution...but problem is...if task 1 start second task2 is stop..but this stop time..we not. use another task...
that is we use thread...
multiple task run at a time parallel way
..is called as thread.
run method is reserve method..
if we call start all run method run parallel..way.
I hope you understand.
+ 3
To understand thread Let me give an example..
In earlier days and in some OS now also when we open a web page data gets loaded and it comes in a proper sequence...
like first text..then gif..then video...
and thus it is the work of thread to present everything in a sequential maner and one task precedes the other.
+ 2
Threads are useful for multitasking purpose..
Here is an example:
Assume that you are playing a game at the same time you want to listen music.. that means multitasking at a same period of time..
Threads are useful to run multiple tasks concurrently like as to play music and video game and alot more.