I am new to programming and I just started working with Applets on Java
. I saw the command getState and understand what it's doing to the specific code but I don't know what it actually does. What is the function of getState()
command on Java
? What do we use it for?
Asked
Active
Viewed 742 times
-1

elseeer
- 1
- 1
-
Google is your friend – Kars Mar 03 '19 at 22:21
1 Answers
0
Here's a quick example of the usage of getState() I found after searching:
package com.tutorialspoint;
import java.lang.*;
public class ThreadDemo implements Runnable {
public void run() {
// returns the state of this thread
Thread.State state = Thread.currentThread().getState();
System.out.println(Thread.currentThread().getName());
System.out.println("state = " + state);
}
public static void main(String args[]) {
Thread t = new Thread(new ThreadDemo());
// this will call run() function
t.start();
}
}
Compiling and running gives us
Thread-0
state = RUNNABLE