-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestThread1.java
More file actions
48 lines (43 loc) · 1.24 KB
/
TestThread1.java
File metadata and controls
48 lines (43 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* TestThread.java
*
* This thread is used to demonstrate how the scheduler operates.
* This thread runs forever, periodically displaying its name.
*
* @author Greg Gagne, Peter Galvin, Avi Silberschatz
* @version 1.0 - July 15, 1999.
* Copyright 2000 by Greg Gagne, Peter Galvin, Avi Silberschatz
* Applied Operating Systems Concepts - John Wiley and Sons, Inc.
*/
class TestThread1 extends Thread
{
private String name;
public TestThread1( String args[] ) {
name = args[0];
SysLib.cout( "TestThread1: " + this + "constructor invoked "
+ name + "\n" );
}
public TestThread1( ) {
name = "none";
SysLib.cout( "TestThread1: " + this + " constructor invoked "
+ name + "\n" );
}
public void run() {
/*
* The thread does something
**/
SysLib.cout( "TestThread1: current pri=" + getPriority( ) + "\n" );
SysLib.cout( "I am thread " + name + "\n" );
if ( name != null && name != "none" ) {
String[] args = SysLib.stringToArgs( "TestThread1" );
SysLib.exec( args );
SysLib.join( );
}
for (int i = 0; i < 10; i++) {
SysLib.cout( "I am thread " + name + "\n" );
SysLib.sleep( 300 );
}
SysLib.sync( );
SysLib.exit( );
}
}