public class ThreadTest { public static void main(String[] args) throws InterruptedException { //1번 Thread thread1 = new Thread(new Worker("11")); Thread thread2 = new Thread(new Worker("22")); //2번 //thread1.setName("A2"); //thread2.setName("B2"); thread1.start(); thread2.start(); } private static class Worker implements Runnable { private String name; public Worker(String name) { this.name = name; } @Override public void run() { Thread currentThread = Thread.currentThread(); currentThread.setName(this.name); System.out.println(Thread.currentThread().getName() + "//thread started"); } } }
'Lang > Java' 카테고리의 다른 글
Quartz 간단하게 사용법 (0) | 2023.02.18 |
---|---|
Java ArrayList, Map multiThread (0) | 2023.02.12 |
sts thymeleaf ',' expected Language Servers (0) | 2022.11.20 |
STS thymeleaf 자동 완성 안 될 때 (0) | 2022.11.20 |
404 에러 Origin 서버가 대상 리소스를 위한 현재의 representation을 찾지 못했거나, 그것이 존재하는지를 밝히려 하지 않습니다. (0) | 2022.01.16 |