-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
70 lines (47 loc) · 2.16 KB
/
Solution.java
File metadata and controls
70 lines (47 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//Remember the word that I said to you: 'A servant is not greater than his lord.' If they persecuted me, they will also persecute you. If they kept my word, they will keep yours also.(John 15:20)
package com.javarush.task.task16.task1604;
/*
Вывод стек-трейса
*/
public class Solution {
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new SpecialThread());
thread.start();
System.out.println("*****************");
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
System.out.println(element);
}
}
public static class SpecialThread implements Runnable {
public void run() {
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
System.out.println(element);
}
}
}
}
/*
Вывод стек-трейса
1. Создать таск (public static класс SpecialThread, который реализует интерфейс Runnable).
2. SpecialThread должен выводить в консоль свой стек-трейс.
Подсказка: main thread уже выводит в консоль свой стек-трейс.
Требования:
1. Добавь в класс Solution публичный статический класс SpecialThread.
2. Класс SpecialThread не должен быть унаследован от какого-либо дополнительного класса.
3. Класс SpecialThread должен реализовывать интерфейс Runnable.
4. Метод run класса SpecialThread должен выводить свой стек-трейс.
package com.javarush.task.task16.task1604;
*
Вывод стек-трейса
*
public class Solution {
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new SpecialThread());
thread.start();
System.out.println("*****************");
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
System.out.println(element);
}
}
}
*/