Last change
on this file since 12 was 2, checked in by Mattia Monga, 14 years ago |
Importazione sorgenti
|
File size:
782 bytes
|
Rev | Line | |
---|
[2] | 1 | class ClasseAttiva extends Thread{
|
---|
| 2 | public void run(){
|
---|
| 3 | while (true) {
|
---|
| 4 | try {
|
---|
| 5 | Thread.sleep(100);
|
---|
| 6 | }
|
---|
| 7 | catch(InterruptedException e){
|
---|
| 8 | System.err.println(e);
|
---|
| 9 | }
|
---|
| 10 | System.out.println(this.getName());
|
---|
| 11 | }
|
---|
| 12 | }
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | public class Basic {
|
---|
| 16 | public static final void main(final String[] args) {
|
---|
| 17 | ClasseAttiva o1 = new ClasseAttiva();
|
---|
| 18 | ClasseAttiva o2 = new ClasseAttiva();
|
---|
| 19 | o1.start();
|
---|
| 20 | o2.start();
|
---|
| 21 | while (true){
|
---|
| 22 | try {
|
---|
| 23 | Thread.sleep(100);
|
---|
| 24 | }
|
---|
| 25 | catch(InterruptedException e){
|
---|
| 26 | System.err.println(e);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | System.out.println("Main thread");
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.