Can We Start A Thread Two Times In Java

[Solved] Can We Start A Thread Two Times In Java | Swift - Code Explorer | yomemimo.com
Question : Can we start a thread two times in Java?

Answered by : pragya-keshap

{"tags":[{"tag":"p","content":"No. We can call start() method only once on a thread in Java. If we\n"},{"tag":"p","content":"call it twice, it will give us exception"},{"tag":"p","content":""},{"tag":"textarea","content":"public class TestThreadTwice1 extends Thread{ \n public void run(){ \n System.out.println(\"running...\"); \n } \n public static void main(String args[]){ \n TestThreadTwice1 t1=new TestThreadTwice1(); \n t1.start(); \n t1.start(); \n } \n} ","code_language":"java"},{"tag":"p","content":"<a target=\"_blank\" href=\"https://www.javatpoint.com/can-we-start-a-thread-twice#:~:text=No.,time%2C%20it%20will%20throw%20exception.\">https://www.javatpoint.com/can-we-start-a-thread-twice#:~:text=No.,time%2C%20it%20will%20throw%20exception.</a>"},{"tag":"p","content":""}]}

Source : | Last Update : Sat, 11 Feb 23

Answers related to can we start a thread two times in java

Code Explorer Popular Question For Swift