⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readsortarray.java

📁 There is a shared object – int array[] between Write and Read. Write sets the array, Read gets the a
💻 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 ReadSortArray extends Thread {
  private ArraySynchronized sharedArray;
  private int times;
  private JTextArea textarea;

  // initialize ReadSortArray thread object
  public ReadSortArray(ArraySynchronized shared, int x, JTextArea output) {
    super("Read and Sort Array Thread");
    sharedArray = shared;
    times = x;
    textarea = output;
  }
  // ProduceInteger thread loops x times and calls
  // sharedObject's setSharedArray method each time
  public void run()
   {
      int t = 0;
      do {
         // sleep for a random interval
         try {
            Thread.sleep( (int) ( Math.random() * 1000 ) );
         }
         // process InterruptedException during sleep
         catch( InterruptedException exception ) {
            System.err.println( exception.toString() );
         }

         sharedArray.getAndsortSharedArray(textarea);
         t++;
      } while ( t != this.times );
   }

}//end class ReadSortArray

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -