This file contains hidden or 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 Threads.Task2.Task4; | |
// Создать поток, который создаст 50 потоков, | |
// каждый их которых выведет на экран свой номер и дождется, пока его прервут. | |
// Прерывание дочерних потоков должно выполнятся из потока их порождающего. | |
public class Main { | |
public static void main(String[] args) { | |
MyThread mt = new MyThread(); |
This file contains hidden or 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 Threads.Task2.Task3; | |
// Создать 100 потоков, каждый их которых выведет на экран свой номер и дождется, пока его прервут. | |
import java.util.ArrayList; | |
public class Main { | |
public static void main(String[] args) { | |
ArrayList<MyThread> list = new ArrayList<>(); |
This file contains hidden or 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 Counter; | |
// Модифицировать класс Counter так, чтобы он циклически выводил числа из определенного диапазона. | |
public class Main { | |
public static class Counter extends Thread { | |
int from, to, sleep; | |
public Counter (int from, int to, int sleep) { | |
this.from = from; |
This file contains hidden or 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 Threads.Task2; | |
// Создать поток, который будет каждые 10 секунд выводить текущее время на экран. | |
// Сделать возможность прерывания потока с помощью команды с консоли. | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { |
This file contains hidden or 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 Monitor; | |
import java.io.File; | |
import java.util.Arrays; | |
public class FileEvent implements IFileEvent { | |
@Override | |
public void onFileAdded(File fdir) { | |
System.out.println("Directory includes files .txt" + Arrays.toString(fdir.list())); | |
} |
This file contains hidden or 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 Monitor; | |
public class FileEvent implements IFileEvent { | |
@Override | |
public void onFileAdded() { | |
System.out.println("Files added!"); | |
} | |
} |
This file contains hidden or 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 Student; | |
// Модифицировать проект «Список студентов» так, чтобы | |
// 1) список вводился с клавиатуры | |
// 2) была возможность удалять студента по номеру | |
// 3) при введении неправильных данных (пустое имя, неправильная дата) программа кидала исключение | |
// и обрабатывала его с выводом соотв. сообщений на экран. | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; |
This file contains hidden or 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 MyExceptions; | |
// Придумать свое исключение и написать соответствующий класс и использующий его код. | |
import java.util.InputMismatchException; | |
import java.util.Scanner; | |
public class MainClass { | |
public static void main(String[] args) { |
This file contains hidden or 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 com.Module2.Lesson1.Lesson3; | |
// Написать аналог Integer.parseInt. Использовать исключения. | |
import java.util.Scanner; | |
public class Task3 { | |
public static void main(String[] args) { | |
Scanner scan = new Scanner(System.in); |
This file contains hidden or 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 com.Module2.Lesson1.Lesson3; | |
// Найти в стандартной библиотеке 5 классов, методы которых кидают исключения | |
// и написать пример кода для их обработки (пример: Integer.parseInt). | |
import java.lang.reflect.Array; | |
import java.util.*; | |
public class Task2 { |