We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e82e68 commit b59b5f8Copy full SHA for b59b5f8
src/main/java/com/examplehub/basics/ThreadExample.java
@@ -0,0 +1,32 @@
1
+package com.examplehub.basics;
2
+
3
+public class ThreadExample extends Thread {
4
5
+ public ThreadExample(String threadName) {
6
+ this.setName(threadName);
7
+ }
8
9
+ @Override
10
+ public void run() {
11
+ while (true) {
12
+ try {
13
+ printThreadInfo();
14
+ Thread.sleep(1000);
15
+ } catch (InterruptedException e) {
16
+ e.printStackTrace();
17
18
19
20
21
+ public static void printThreadInfo() {
22
+ System.out.println(Thread.currentThread().getName() + " is running");
23
24
25
+ public static void main(String[] args) throws InterruptedException {
26
+ new ThreadExample("myThread").start();
27
28
29
30
31
32
+}
0 commit comments