Created
April 18, 2023 16:41
-
-
Save gunkim/af1c0123ffcebee5648197207c3502e9 to your computer and use it in GitHub Desktop.
스레드 타이핑 연습
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.gunkim | |
fun main() { | |
val thread = Thread { | |
System.out.printf("현재 스레드 : %s%n", Thread.currentThread().name) | |
System.out.printf("현재 스레드에는 우선순위가 설정되었음. %s", Thread.currentThread().priority) | |
}.apply { | |
name = "새 작업 스레드" | |
priority = Thread.MAX_PRIORITY | |
uncaughtExceptionHandler = Thread.UncaughtExceptionHandler { t: Thread, e: Throwable -> | |
System.out.printf( | |
"예외가 발생했습니다. 스레드 : %s, 예외 : %s%n", | |
t.name, | |
e.message | |
) | |
} | |
} | |
System.out.printf("실행 전 스레드 : %s%n", Thread.currentThread().name) | |
thread.start() | |
System.out.printf("실행 후 스레드 : %s%n", Thread.currentThread().name) | |
Thread.sleep(10000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment