KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > connection > timeout > gridImpl


1 package test.connection.timeout;
2
3 /**
4  * A very simple implementation of a 2-D grid
5  */

6
7
8 public class gridImpl
9     extends MyServerPOA
10 {
11     protected short height = 31;
12     protected short width = 14;
13     protected java.math.BigDecimal JavaDoc[][] mygrid;
14
15     private void sleep( int how_long )
16     {
17         try
18         {
19             System.out.println( "Going to sleep...");
20             Thread.currentThread().sleep( how_long );
21         }
22         catch( InterruptedException JavaDoc ie )
23         {
24             ie.printStackTrace();
25         }
26         System.out.println( "Awake again");
27     }
28
29  
30     public gridImpl()
31     {
32         mygrid = new java.math.BigDecimal JavaDoc[height][width];
33         for( short h = 0; h < height; h++ )
34         {
35             for( short w = 0; w < width; w++ )
36             {
37                 mygrid[h][w] = new java.math.BigDecimal JavaDoc("0.21");
38             }
39         }
40     }
41
42     public java.math.BigDecimal JavaDoc get(short n, short m)
43     {
44         sleep( 20000 );
45         if( ( n <= height ) && ( m <= width ) )
46             return mygrid[n][m];
47         else
48             return new java.math.BigDecimal JavaDoc("0.01");
49     }
50
51     public short height()
52     {
53         sleep( 20000 );
54         return height;
55     }
56
57     public void set(short n, short m, java.math.BigDecimal JavaDoc value)
58     {
59         sleep( 20000 );
60         if( ( n <= height ) && ( m <= width ) )
61             mygrid[n][m] = value;
62     }
63
64     public short width()
65     {
66         sleep( 20000 );
67         return width;
68     }
69
70
71
72 }
73
74
75
Popular Tags