Biblioteca Java - Blame information for rev 3
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
3 | mihai | 1 | /* |
2 | * NumaratorR.java | ||
3 | */ | ||
4 | package lab.scd.fire.runnable; | ||
5 | |||
6 | /** | ||
7 | * Class created by @author Mihai HULEA at Feb 12, 2005. | ||
8 | * | ||
9 | * This class is part of the labs project. | ||
10 | * | ||
11 | * Aceasta clasa ilustreaza modul in care se pot implementa firele de executie utilizand | ||
12 | * interfata Runnable. | ||
13 | * | ||
14 | * Teme | ||
15 | * | ||
16 | * 1. Verificati functionarea programului | ||
17 | * | ||
18 | * 2. Verificati al doilea mod de lansare in executie a firelor (sectiunea de cod comentata | ||
19 | * din cadrul metodei main) | ||
20 | * | ||
21 | * 3. Modificati programul NumaratorT astfel incat acesta sa foloseasca interfata Runnable | ||
22 | * pentru lucrul cu fire. | ||
23 | */ | ||
24 | public class NumaratorR implements Runnable { | ||
25 | |||
26 | Thread t; | ||
27 | |||
28 | public void start(){ | ||
29 | if(t!=null){ | ||
30 | t = new Thread(this); | ||
31 | t.start(); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | public void run() { | ||
36 | System.out.println("Firul ruleaza."); | ||
37 | } | ||
38 | |||
39 | public static void main(String[] args) { | ||
40 | NumaratorR nr = new NumaratorR(); | ||
41 | nr.start(); | ||
42 | |||
43 | //Un alt mod de lansare a executie a firului fara a mai fi nevoie de implementarea | ||
44 | // metodei start in cadrul clasei NumaratorR | ||
45 | //Thread t = new Thread(nr); | ||
46 | //t.start(); | ||
47 | |||
48 | } | ||
49 | |||
50 | } |