Yurttas/PL/OOL/Java/F/07/04/Producer.java

From ZCubes Wiki
Revision as of 15:23, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="java" line start="1" enclose="div">/** * Copyright(C) 1998 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. * * P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 1/**
 2 *  Copyright(C) 1998
 3 *  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4 *
 5 *  Permission to use, copy, modify, and distribute this
 6 *  software and its documentation for EDUCATIONAL purposes
 7 *  and without fee is hereby granted provided that this
 8 *  copyright notice appears in all copies.
 9 *
10 *  @date   : January 1, 1998.
11 *  @author : Salih Yurttas.
12 */
13
14
15public class Producer extends Thread {
16
17  private CubbyHole cubbyhole;
18  private int number;
19
20  public Producer(CubbyHole c,
21                  int number) {
22    cubbyhole = c;
23    this.number = number;
24  }
25
26  public void run() {
27    for(int i=0; i<10; i++) {
28      cubbyhole.put(i);
29      System.out.println("Producer #"+
30                         this.number+
31                         " put: "+
32                         i);
33      try {
34        sleep((int)(Math.random() * 100));
35      }
36      catch(InterruptedException iE) {}
37    }
38  }
39
40}