-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
78 lines (55 loc) · 2.46 KB
/
Solution.java
File metadata and controls
78 lines (55 loc) · 2.46 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
71
72
73
74
75
76
77
78
//If you were of the world, the world would love its own. But because you are not of the world,
//since I chose you out of the world, therefore the world hates you (John 15:19)
package com.javarush.task.task16.task1603;
import java.util.ArrayList;
import java.util.List;
/*
Список и нити
*/
public class Solution {
public static volatile List<Thread> list = new ArrayList<Thread>(5);
public static void main(String[] args) {
SpecialThread thread0 = new SpecialThread();//Add your code here - добавьте свой код тут
SpecialThread thread1 = new SpecialThread();
SpecialThread thread2 = new SpecialThread();
SpecialThread thread3 = new SpecialThread();
SpecialThread thread4 = new SpecialThread();
list.add(new Thread(thread0));
list.add(new Thread(thread1));
list.add(new Thread(thread2));
list.add(new Thread(thread3));
list.add(new Thread(thread4));
}
public static class SpecialThread implements Runnable {
public void run() {
System.out.println("it's a run method inside SpecialThread");
}
}
}
/*
Список и нити
В методе main добавить в статический объект list 5 нитей. Каждая нить должна быть новым объектом класса Thread, работающим со своим объектом класса SpecialThread.
Требования:
1. В методе main создай 5 объектов типа SpecialThread.
2. В методе main создай 5 объектов типа Thread.
3. Добавь 5 разных нитей в список list.
4. Каждая нить из списка list должна работать со своим объектом класса SpecialThread.
5. Метод run класса SpecialThread должен выводить "it's a run method inside SpecialThread".
package com.javarush.task.task16.task1603;
import java.util.ArrayList;
import java.util.List;
*
Список и нити
*
public class Solution {
public static volatile List<Thread> list = new ArrayList<Thread>(5);
public static void main(String[] args) {
//Add your code here - добавьте свой код тут
}
public static class SpecialThread implements Runnable {
public void run() {
System.out.println("it's a run method inside SpecialThread");
}
}
}
*/