Grokking The Java Developer Interview: More Than 200 Questions To Crack The Java, Spring, SpringBoot & Hibernate Interview



Download 7,31 Mb.
Pdf ko'rish
bet54/89
Sana21.04.2022
Hajmi7,31 Mb.
#571320
1   ...   50   51   52   53   54   55   56   57   ...   89
Bog'liq
Grokking-The-Java-Developer-Interview-More-Than-200-Questions-To-Crack-The-Java -Spring -SpringBoot-

Multi-threading:
you will be asked many questions on multi-
threading, so, read as much as you can and whatever you can.
Here, I am including some of the important questions that are mostly
asked in every interview.
Question 71: What is Multi-threading?
Answer: Multi-threading is a process of executing two or more
threads concurrently, utilizing available CPU resources. A single
thread is a lightweight sub-process and the smallest unit of
processing. Threads are independent, if any exception occurs in one
thread, it does not affect other threads.
When we execute a Java program without making any separate
thread, then also our program runs on a thread called ‘main thread’.
There are 2 types of threads in an application, user thread and
daemon thread. When the application is first started, main thread is
the first user thread created. We can create multiple user threads
and daemon threads.
One thing to remember here is that, JVM does not have any control
on a thread’s execution. The thread execution is controlled by
Thread scheduler which is part of Operating System. A thread can
be assigned a priority using setPriority(int) method, where 1 is the
minimum and 10 is the maximum priority, however thread priority is
not guaranteed as it is platform dependent.
Multi-threading is used in a time-consuming task, one common
example is File Upload.
Question 72: How to create a thread in Java?
Answer: There are 2 ways to create a thread:
By extending Thread class
By implementing Runnable
interface
By extending Thread class:


ThreadTest.java:
Output:
Here a Task class extends Thread class and overrides the run()
method which contains the business logic, then we make an object
of this Task and call the start() method, which starts the thread
execution. start() method internally calls run() method .

Download 7,31 Mb.

Do'stlaringiz bilan baham:
1   ...   50   51   52   53   54   55   56   57   ...   89




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish