?? writearray.java
字號:
package cwq4;
import javax.swing.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class WriteArray extends Thread {
private ArraySynchronized sharedArray;
private int times;
private JTextArea textarea;
// initialize WriteArray thread object
public WriteArray(ArraySynchronized shared, int x, JTextArea output) {
super("Write Array Thread");
sharedArray = shared;
times = x;
this.textarea = output;
}
// ProduceInteger thread loops x times and calls
// sharedObject's setSharedArray method each time
public void run(){
for ( int count = 1; count <= this.times; count++ ) {
// sleep for a random interval
try {
Thread.sleep( ( int ) ( Math.random() * 1000 ) ); }
// process InterruptedException during sleep
catch( InterruptedException exception ) {
System.err.println( exception.toString() ); }
// call sharedObject method from this thread of execution
sharedArray.setSharedArray(textarea);
}
}
}// end class WriteArray
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -