На 16 уровне в 9 лекции у нас примерно такой код, который создает объект класса и нить для него
class Printer implements Runnable
{
private String name;
public Printer(String name)
{
this.name = name;
}
public void run()
{
System.out.println("I’m " + this.name);
}
}
public static void main(String[] args)
{
Printer printer1 = new Printer("Коля");
Thread thread1 = new Thread(printer1);
thread1.start();
thread1.join();
}
Через пару лекций кое-как решаю задачку созданием вот такого шедевра
public class Solution {
public static void main(String[] args) throws InterruptedException {
TestThread test = new TestThread();
Thread testthread = new Thread(test);
test.start();
test.interrupt();
}
//Add your code below - добавь код ниже
public static class TestThread extends Thread {
public void run() {
}
}
}
Вопрос 1:
Когда в задачке писал testthread.start(); и testthread.interrupt(); не проходило, но ведь мы же запускаем созданную нить, разве нет? Именно так было в лекции..
Вопрос 2:
Почему класс TestThread внутри класса Solution ?