Why do we use threads in Java?

0 votes
Nov 2, 2018 in Java by jhanvi
• 120 points

edited Nov 2, 2018 by Vardhan 75 views

1 answer to this question.

0 votes

Reasons for using Multithreading in Java:

  • When a Java program starts, the Java Virtual Machine  creates the main thread and calls the program's main() method within that thread. 
  • use to execute the multiple loops in one window. 
  • Threads are use to perform asynchronous or background processing.

Java application contains contain  at least one thread, that is called main thread which executes your main method. There are more threads used by JVM e.g. daemon threads which do garbage collections and some other housekeeping works. As an application developer, you can also add new user threads to make your application faster and more efficient. 

answered Nov 2, 2018 by nsv999
• 5,110 points

Related Questions In Java

0 votes
2 answers

What is the use of @Override annotation in Java ? When do we use it ?

@Override annotation is used when we override ...READ MORE

answered Aug 14 in Java by Sirajul
• 35,810 points
111 views
0 votes
1 answer

What do we understand from string pool in java?

This prints true (even though we don't use equals method: correct ...READ MORE

answered Apr 30, 2018 in Java by Daisy
• 8,050 points
43 views
0 votes
3 answers

How can we use java.String.format in Scala?

String aString = "world"; int aInt = 20; String.format("Hello, ...READ MORE

answered Aug 29, 2018 in Java by Daisy
• 8,050 points
234 views
0 votes
1 answer

Can we use multiline String in Java?

It is not possible directly to use Multiline ...READ MORE

answered Jun 19, 2018 in Java by sharth
• 3,350 points
94 views
0 votes
1 answer

How can we use wait and notify in Java?

You can refer to this: synchronized (someObject) { ...READ MORE

answered Jul 12, 2018 in Java by sophia
• 1,400 points
30 views
0 votes
1 answer

difference between wait() and sleep() in java

We can find a big difference between ...READ MORE

answered Apr 25, 2018 in Java by developer_1
• 3,300 points
72 views
0 votes
1 answer

How to kill a thread in Java?

You can use a shared variable as ...READ MORE

answered Jun 6, 2018 in Java by Akrati
• 3,150 points
86 views
0 votes
1 answer

How to stop the Thread in Java?

Use a flag, which will indicate the ...READ MORE

answered Jun 11, 2018 in Java by parth295
• 4,640 points
91 views
0 votes
1 answer

Gracefully stopping a java thread

The preferable way will be to use a ...READ MORE

answered Aug 20, 2018 in Java by anto.trigg4
• 3,420 points
40 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
560 views