Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
92 views

Daemon Thread Sample Code Examples - Java Sample Programs

Daemon Thread Sample Code Examples - Java Sample Programs
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

Daemon Thread Sample Code Examples - Java Sample Programs

Daemon Thread Sample Code Examples - Java Sample Programs
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

2/14/14

Daemon thread sample code examples - Java Sample Programs

JAVA EXAMPLE PROGRAMS


0

Home Fundamentals Constructors Exception Handling Threads String Functions Generics Collections & Util Package Nested Classes Networking File I/O Operations Java Annotations JDBC Examples Java Interview Questions Java Interview Programs JUnit Search Algorithms Sorting Algorithms Data Structures JBoss Configurations

Java Daemon Thread Examples


You can make any java thread as daemon thread. Daemon threads acts like service providers for other threads running in the same process. Daemon threads will be terminated by the JVM when there are none of the other threads running, it includs main thread of execution as well. To specify that a thread is a daemon thread, call the setDaemon method with the argument true. To determine if a thread is a daemon thread, use the accessor method isDaemon.

Daemon Thread Sample Code


1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 p a c k a g ec o m . m y j a v a . t h r e a d s ; p u b l i cc l a s sD a e m o n T h r e a de x t e n d sT h r e a d { p u b l i cD a e m o n T h r e a d ( ) { s e t D a e m o n ( t r u e ) ; } p u b l i cv o i dr u n ( ) { S y s t e m . o u t . p r i n t l n ( " I st h i st h r e a dD a e m o n ?-" + i s D a e m o n ( ) ) ; } p u b l i cs t a t i cv o i dm a i n ( S t r i n ga [ ] ) { D a e m o n T h r e a dd t=n e wD a e m o n T h r e a d ( ) ; / /e v e ny o uc a ns e td a e m o nc o n s t r a i nh e r ea l s o / /i ti sl i k ed t . s e t D e a m o n ( t r u e ) d t . s t a r t ( ) ; }
?

Knowledge Center Interface and its usage

Example Output
Is this thread Daemon? - true

Other Thread Examples


By Implementing Runnable Interface Example By Extending Thread Class Example Thread Join Example Thread Sleep Example Thread Yield Example

Interface is similar to a class which contain method's signature only bu and it is a formal set of method an declarations that must be defined that implements it. Interfaces are declaring methods that one or mor expected to implement, capturing between unrelated classes without class relationship and determining programming interface without rev actual body of the class.

Find us on Facebook

Java Sample Programs


Like 1,608 people like Java Sample Programs

Facebook social plugin

www.java2novice.com/java_thread_examples/daemon_threads/

1/2

2/14/14

Daemon thread sample code examples - Java Sample Programs


Few Random Java Examples

What is generics wildcard argumen example. Write a program to find maximum words from a file.

Find out duplicate number between numbers.

Can you serialize static fields of a c

Placement Java Interview Question

How to convert byte array to inputs

How to get subset from sorted set?

How implement bounded types (imp interface) with generics? How to zip a single file?

About Author
My name is Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment. If you come across any mistakes or bugs, please email me at java2novice@gmail.com or you can comment on the page.

Most Visited Pages


Freshers Java Interview Questions How to Create Java Custom Exception How to convert byte array to inputstream? Java StringTokenizer With Multiple De-limiters Sample Code Java Constructor Chaining Examples Write a program to find out duplicate characters in a string. Write a program to find maximum repeated words from a file. How to read file content using byte array?

Other Interesting Sites


Techie Park Wikipedia query2nataraj.blogspot.in

Reference: Java Platform Standard Ed. 6 - API Specification | Java is registered trademark of Oracle. Privacy Policy | Copyright 2013 by Nataraja Gootooru. All Rights Reserved.

www.java2novice.com/java_thread_examples/daemon_threads/

2/2

You might also like