From dfa68cf46d31fe61220464844b09b12a92ef4c00 Mon Sep 17 00:00:00 2001 From: Giovanni Di Grezia Date: Sun, 5 Oct 2014 13:59:42 +0200 Subject: [PATCH] alcuni test sui thread nella classe start --- start.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/start.java b/start.java index 4928d8b..adff86f 100644 --- a/start.java +++ b/start.java @@ -3,8 +3,50 @@ */ public class start { + public static class xthread implements Runnable{ + @Override + public void run() { + try { + for (int i = 0;i<10;i++) { + + System.out.println("alee"); + Thread.currentThread().sleep(1000); + + } + }catch (InterruptedException e) { + + System.out.println("manno acciso"); + } + + } + } + public static void main (String[] args){ +try { + + xthread a = new xthread(); + Thread t = new Thread(a); + t.start(); + + t.join(5000); + if (t.isAlive()) { + t.interrupt(); + t.join(); + System.out.println("killato e uscito"); + }else { + System.out.println("uscito"); + } + + + +} +catch (InterruptedException e){ + +} + + + }