Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 460d05e

Browse files
Challenge 54.
Thread start method, IllegalThreadStateException.
1 parent c97cfb6 commit 460d05e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package challenge51_60;
2+
3+
/**
4+
* To create a thread ---> we can inherit from the Thread class.
5+
* To run the thread ---> thread.start()
6+
* thread.join() --->
7+
*
8+
* We can't start a thread more than one time.
9+
*
10+
*/
11+
public class Challenge_54 {
12+
13+
public static void main( String[] args ) throws InterruptedException {
14+
Thread thread = new MyThread();
15+
thread.start();
16+
thread.join();
17+
18+
thread.start();
19+
thread.join();
20+
}
21+
22+
static class MyThread extends Thread{
23+
@Override
24+
public void run(){
25+
System.out.println("I'm alive");
26+
}
27+
}
28+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /