Capitolo 7
This presentation is the property of its rightful owner.
Sponsored Links
1 / 2

CAPITOLO 7 PowerPoint PPT Presentation


  • 68 Views
  • Uploaded on
  • Presentation posted in: General

CAPITOLO 7. JAVA: MULTITHREADING E PROGRAMMAZIONE CONCORRENTE. PROGRAMMAZIONE MULTITHREAD. public class Multithread { public static void main (String args[]) { TestThrd t1, t2, t3;

Download Presentation

CAPITOLO 7

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Capitolo 7

CAPITOLO 7

JAVA: MULTITHREADING E PROGRAMMAZIONE CONCORRENTE


Programmazione multithread

PROGRAMMAZIONE MULTITHREAD

public class Multithread {

public static void main (String args[]) {

TestThrd t1, t2, t3;

t1 = new TestThrd("Din"; (int)(Math.random())*2000); t2 = new TestThrd("Don"; (int)(Math.random())*2000); t3 = new TestThrd("Dan"; (int)(Math.random())*2000);

t1.start(); t2.start(); t3.start(); }

class TestThrd extends Thread {

private String whoami; private int delay;

public TestThrd(String s, int d) {

whoami = s; delay = d; }

public void run() { try { sleep(delay); }

catch (InterruptedException e) {} ;

System.out.println(whoami) ; } }


  • Login