Пример #1
0
 /**
  * 变更窗体匹配的图像组件大小
  *
  * @param w
  * @param h
  */
 public void resize() {
   this.id = ThreadID.get();
   if (handler != null) {
     int w = handler.getWidth(), h = handler.getHeight();
     if (w < 1 || h < 1) {
       w = h = 1;
     }
     if (w != tmp_width || h != tmp_height) {
       tmp_width = w;
       tmp_height = h;
     } else {
       Thread.yield();
       return;
     }
   }
   this.setBackground(GraphicsUtils.createIntdexedImage(tmp_width, tmp_height));
   this.flvVideo = new FLVEngine(tmp_width, tmp_height);
   this.sprites = new Sprites(tmp_width, tmp_height);
   this.desktop = new Desktop(baseInput, tmp_width, tmp_height);
 }
Пример #2
0
  @Override
  public Void call() throws Exception {

    id = ThreadID.get();
    mBuffer.setId(id);
    tsStack.tsThreads[id] = this;

    Random rand = new Random();

    // Execute a push or pop on the stack. The frequency of push is controlled by percPush
    for (int i = 0; i < nOps; i++) {
      int x = rand.nextInt(100) + 1;
      if (x <= percPush) {
        ins(TsStackTest.idx.getAndIncrement());
      } else {
        tsStack.tryRem(System.nanoTime());
      }
    }
    return null;
  }