Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.mycompany.app24;
- //
- import java.util.concurrent.TimeUnit;
- public class Main {
- public static void main(String[] args) {
- //
- // Thread th = new Thread(new MyTask());
- // th.start();
- // создаем поток и запускаем его с помощью метода start()
- //new Thread(new MyTask()).start();
- // использование лямбда-вырвжения для реализации метода run()
- Runnable r = () -> {
- System.out.println("MyTaskLambda.run>>");
- try {
- //Thread.sleep(2000);
- TimeUnit.SECONDS.sleep(2);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("<<");
- };
- new Thread(r).start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement