
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use isAlive() method of Thread class in Java?
The isAlive() method of the Thread class returns true if the thread is alive, which is anytime after the thread has been started but before it runs to completion.
Example
class first implements Runnable { public void run() { try { for(int i=0; i<=20; i+=2) { Thread.sleep(600); System.out.println(i); } } catch(Exception e) { } } class MyThread { public static void main(String args[]) { first obj = new first(); Thread thread = new Thread(obj); thread.setPriority(Thread.MAX_PRIORITY); thread.start(); System.out.println(thread.isAlive()); } }
Output
true 0 2 4 6 8 10 12 14 16 18 20
- Related Questions & Answers
- isAlive() method of Thread Class in Java programming
- The join() method of Thread Class in Java
- How to use subSet() method of Java NavigableSet Class
- How to use headSet() method of Java NavigableSet Class
- How to use the substring() method of java.lang.String class in Java?
- How to make a class thread-safe in Java?
- How to use ReadKey() method of Console class in C#?
- How to use WriteLine() method of Console class in C#?
- Properties of the Thread Class
- Methods of the Thread Class
- What is the Thread class in Java?
- How to create a thread by using anonymous class in Java?
- How to use file class in Java?
- How to use the Clear method of array class in C#?
- How to use the Clone() method of array class in C#?
Advertisements