/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
-javaagent:/Applications/IntelliJ
IDEA CE.app/Contents/lib/idea_rt.jar=49386:/Applications/IntelliJ
IDEA CE.app/Contents/bin
-Dfile.encoding=UTF-8
-classpath /Users/code2care/IdeaProjects/multi-tasking/out/production/multi-tasking
MyThread
Exception in thread "main" java.lang.IllegalThreadStateException
at java.base/java.lang.Thread.start(Thread.java:789)
at MyThread.main(MyThread.java:8)
This is Main Thread
This is my Thread
Process finished with exit code 1
✏️ IllegalThreadStateException is thrown to indicate that a thread is not in an appropriate state for the requested operation.
Example, you will see java.lang.IllegalThreadStateException when you are using Multi-Threading in your Java program and you start the same thread more than one!
Example:/**
* Java Code Example: code2care.org
*/
public class MyThread extends Thread {
public static void main(String[] args) {
MyThread thread = new MyThread();
thread.start();
System.out.println("This is Main Thread");
thread.start(); //IllegalThreadStateException
}
@Override
public void run() {
System.out.println("This is my Thread");
}
}

The above code can be fixed by making sure that once the thread is not started multiple times.
- Error: Can not find the tag library descriptor for
- Create a Database Table using JDBC PreparedStatement
- Java JDBC Select Multiple Records from table as List using PreparedStatement
- Java Jackson with Maven Example
- [fix] Java JDBC ConnectException: Connection refused
- Spring Boot: Transactions Management with JDBCTemplate Example
- Java Get Current Date for a Specific Time Zone
- What are the 8 Primitive Data Types in Java
- Java JDBC: Insert Java 8 LocalDate and Time using PreparedStatement
- Maven Eclipse (M2e) No archetypes currently available
- How to Sort a LinkedList in Java
- [Fatal Error] XML The markup in the document following the root element must be well-formed.
- Split a String in Java with Examples
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- Truncate table using Java JDBC Example
- Java: Generate random numbers within a range
- Parse XML file in Java using DOM Parser
- How to get Client IP address using Java Code Example
- JDBCTemplate Querying Examples with Spring Boot 3
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- String Boot + Redis - SET and GET String Commands Examples
- Setting up Spring Boot 3 + Maven + MySQL + JDBC Example
- Spring Boot: JdbcTemplate Update Query With Parameters Example
- Java Split String by Spaces
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- Unzip a Zip file from Terminal Command - HowTos
- VS Code: The source path must be contained in the project root folder. - Java
- zsh: command not found: cls macOS Big Sur - MacOS
- #HappyBirthdayJimin trending Happy Birthday Jimin BTS Army - BTS
- Rename a directory using Linux/Unix command - Linux
- Convert Java List to Json String using Jackson - Java
- Obsolete marquee element alternatives html5 - Html
- Its almost time - Apple Event September 10 10 am PDT ⚡️ - Apple