- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a daemon thread in Java?
A daemon thread in java is the one which executes continuously in the background. You can set a thread daemon using the method setDaemon().
Example
class adminThread extends Thread { adminThread() { setDaemon(true); } public void run() { boolean d = isDaemon(); System.out.println("daemon = " + d); } } public class ThreadDemo { public static void main(String[] args) throws Exception { Thread thread = new adminThread(); System.out.println("thread = " + thread.currentThread()); thread.setDaemon(true); thread.start(); } }
Output
thread = Thread[main, 5, main]
- Related Articles
- Daemon thread in Java
- User Thread vs Daemon Thread in Java?
- What method is used to create a daemon thread in Java?
- How to get current thread is daemon in android?
- What is the Thread class in Java?
- What are the ways in which a thread is created in Java?
- Is Java matcher thread safe in Java?
- How a thread can interrupt another thread in Java?
- Naming a thread in Java
- Is Swing thread-safe in Java?
- Difference Between Daemon Threads and User Threads In Java
- What is Thread cancellation?
- Thread Pools in Java
- How to create a thread in Java
- How to understand StringBuffer is thread-safe and StringBuilder is non-thread-safe in Java?\n

Advertisements