Java 类java.lang.Runnable 实例源码

项目:Project-Sarica-v3    文件:ThreadOwner.java   
public void begin()
{
    while (running)
    {
        synchronized (tasks)
        {
            int count = tasks.size();
            while (count < 10)
            {
                count++;

                Runnable task = taskMaster.buildNextTask();

                if (task == null)
                    break;

                tasks.add(task);
            }
        }

        try { Thread.sleep(1);
        }catch(Exception exception){}
    }
}
项目:openjdk9    文件:I18NViewNoWrapMinSpan.java   
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            try {
                JTextField textField = new JTextField(15);
                textField.setText("ม12345");
                float noSpaceMin = textField.getUI().getRootView(textField)
                        .getMinimumSpan(0);
                textField.getDocument().insertString(3, " ", null);
                if (noSpaceMin > textField.getUI().getRootView(textField)
                        .getMinimumSpan(0)) {
                    throw new RuntimeException(
                            "Minimum span is calculated for wrapped text");
                }
            } catch (BadLocationException e) {
                throw new RuntimeException(e);
            }
        }
    });
    System.out.println("ok");
}
项目:react-native-incall-manager    文件:InCallManagerModule.java   
private void manualTurnScreenOff() {
    Log.d(TAG, "manualTurnScreenOff()");
    UiThreadUtil.runOnUiThread(new Runnable() {
        public void run() {
            Activity mCurrentActivity = getCurrentActivity();
            if (mCurrentActivity == null) {
                Log.d(TAG, "ReactContext doesn't hava any Activity attached.");
                return;
            }
            Window window = mCurrentActivity.getWindow();
            WindowManager.LayoutParams params = window.getAttributes();
            lastLayoutParams = params; // --- store last param
            params.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF; // --- Dim as dark as possible. see BRIGHTNESS_OVERRIDE_OFF
            window.setAttributes(params);
            window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    });
}
项目:react-native-incall-manager    文件:InCallManagerModule.java   
private void manualTurnScreenOn() {
    Log.d(TAG, "manualTurnScreenOn()");
    UiThreadUtil.runOnUiThread(new Runnable() {
        public void run() {
            Activity mCurrentActivity = getCurrentActivity();
            if (mCurrentActivity == null) {
                Log.d(TAG, "ReactContext doesn't hava any Activity attached.");
                return;
            }
            Window window = mCurrentActivity.getWindow();
            if (lastLayoutParams != null) {
                window.setAttributes(lastLayoutParams);
            } else {
                WindowManager.LayoutParams params = window.getAttributes();
                params.screenBrightness = -1; // --- Dim to preferable one
                window.setAttributes(params);
            }
            window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    });
}
项目:react-native-incall-manager    文件:InCallManagerModule.java   
@ReactMethod
public void setKeepScreenOn(final boolean enable) {
    Log.d(TAG, "setKeepScreenOn() " + enable);
    UiThreadUtil.runOnUiThread(new Runnable() {
        public void run() {
            Activity mCurrentActivity = getCurrentActivity();
            if (mCurrentActivity == null) {
                Log.d(TAG, "ReactContext doesn't hava any Activity attached.");
                return;
            }
            Window window = mCurrentActivity.getWindow();
            if (enable) {
                window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            } else {
                window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            }
        }
    });
}
项目:wava    文件:TestTypeSpec.java   
@Test
public void varargs()
        throws Exception
{
    TypeSpec taqueria = TypeSpec.classBuilder("Taqueria")
            .addMethod(MethodSpec.methodBuilder("prepare")
                    .addParameter(int.class, "workers")
                    .addParameter(Runnable[].class, "jobs")
                    .varargs()
                    .build())
            .build();
    assertThat(toString(taqueria)).isEqualTo(""
            + "package com.squareup.tacos;\n"
            + "\n"
            + "import java.lang.Runnable;\n"
            + "\n"
            + "class Taqueria {\n"
            + "  void prepare(int workers, Runnable... jobs) {\n"
            + "  }\n"
            + "}\n");
}
项目:wava    文件:TestTypeSpec.java   
@Test
public void anonymousClassToString()
        throws Exception
{
    TypeSpec type = TypeSpec.anonymousClassBuilder("")
            .addSuperinterface(Runnable.class)
            .addMethod(MethodSpec.methodBuilder("run")
                    .addAnnotation(Override.class)
                    .addModifiers(Modifier.PUBLIC)
                    .build())
            .build();
    assertThat(type.toString()).isEqualTo(""
            + "new java.lang.Runnable() {\n"
            + "  @java.lang.Override\n"
            + "  public void run() {\n"
            + "  }\n"
            + "}");
}
项目:aidl2    文件:MethodTypeargParcelable$$AidlClientImpl.java   
@Override
public <T extends Runnable & Parcelable> void methodWithParcelableParam(T parcelable) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(MethodTypeargParcelable$$AidlServerImpl.DESCRIPTOR);

        data.writeParcelable(parcelable, 0);

        delegate.transact(MethodTypeargParcelable$$AidlServerImpl.TRANSACT_methodWithParcelableParam, data, reply, 0);
        reply.readException();
    } finally {
        data.recycle();
        reply.recycle();
    }
}
项目:intellij-ce-playground    文件:TestClassSimpleBytecodeMapping.java   
public int test() {

  System.out.println("before");

  run(new Runnable() {
    @Override
    public void run() {
      System.out.println("Runnable");
    }
  });

  test2("1");

  if(Math.random() > 0) {
    System.out.println("0");
    return 0;
  } else {
    System.out.println("1");
    return 1;
  }
}
项目:extension-android-immersive    文件:AndroidImmersive.java   
public static void resetSystemUiVisibility(){
    Handler handler = new Handler();
    Runnable runnable = new Runnable(){
        public void run() {
            if(currentMode == null) return;
            if(currentMode.equals("lowProfile")) {
                _setLowProfile();
            } else if(currentMode.equals("immersive")) {
                _setImmersive();
            } else if(currentMode.equals("statusBarColor")) {
                _setStatusBarColor(-1);
            }
        }
    };
    handler.postDelayed(runnable, DELAY_TIME);
}
项目:testfile    文件:MenuActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection.
    switch (item.getItemId()) {
        case R.id.stop:
            // Stop the service at the end of the message queue for proper options menu
            // animation. This is only needed when starting a new Activity or stopping a Service
            // that published a LiveCard.
            post(new Runnable() {

                @Override
                public void run() {
                    stopService(new Intent(MenuActivity.this, StopwatchService.class));
                }
            });
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
项目:charity-android    文件:MainActivity.java   
private void scrollListViewToTaggedView(String tag) {
    final ListView listview = (ListView) findViewById(R.id.event_listview);
    final Integer index = idToViewIndexMap.get(tag);
    if (index != null) {
        View rowView = listview.getChildAt(index.intValue());
        int h1 = listview.getHeight();
        int h2 = 0;
        if (rowView != null) {
            h2 = rowView.getHeight();
        }
        final int h = h1/2 - h2/2;
        runOnUiThread(new Runnable() {
            public void run() {
                listview.smoothScrollToPositionFromTop(index.intValue(), 0, 300);
                listview.setSelection(index.intValue());
            }
        });
    }
}
项目:arcgis-runtime-demos-android    文件:MenuActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection.
    switch (item.getItemId()) {
        case R.id.stop:
            // Stop the service at the end of the message queue for proper options menu
            // animation. This is only needed when starting a new Activity or stopping a Service
            // that published a LiveCard.
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    stopService(new Intent(MenuActivity.this, MapService.class));
                    setResult(RESULT_OK);
                    finish();
                }
            });
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
项目:tools-idea    文件:ManyClasses.java   
public void foo() {
  Runnable r = new Runnable() {
    @Override
    public void run() {
      Comparable<Integer> c = new Comparable<Integer>() {
        @Override
        public int compareTo(Integer o) {
          return 0;
        }
      };
    }
  };

  class FooLocal {
    Runnable r = new Runnable() {
      @Override
      public void run() {
      }
    };
  }
}
项目:GooglePlayServices-OpenFL    文件:GameActivity.java   
static public void retrievePurchases()
{
    GameActivity.getInstance().runOnUiThread
    (
        new Runnable()
        { 
            public void run() 
            {
                try
                {
                singleton.mHelper.queryInventoryAsync(singleton.mGotInventoryListener); 
                }
                catch(IllegalStateException ex){
                    singleton.mHelper.flagEndAsync();
                }
            }
        }
    );
}
项目:GooglePlayServices-OpenFL    文件:GameActivity.java   
static public void initInterstitial(final String id, final String testDevice) {
    activity.runOnUiThread(new Runnable() {
        public void run() {
if (activity == null) {
    return;
}

if(testDevice.length() > 0)
{
    adTestMode = true;
    testDeviceID = testDevice;
}
else
    adTestMode = false;

            interstitial = new InterstitialAd(activity);
            interstitial.setAdUnitId(id);

            loadInterstitial();
        }
    });
}
项目:gdk-apidemo-sample    文件:MenuActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection.
    switch (item.getItemId()) {
        case R.id.stop:
            // Stop the service at the end of the message queue for proper options menu
            // animation. This is only needed when starting a new Activity or stopping a Service
            // that published a LiveCard.
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    stopService(new Intent(MenuActivity.this, OpenGlService.class));
                }
            });
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
项目:PTVGlass    文件:CompassMenuActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.read_aloud:
            mCompassService.readHeadingAloud();
            return true;
        case R.id.stop:
            // Stop the service at the end of the message queue for proper options menu
            // animation. This is only needed when starting an Activity or stopping a Service
            // that published a LiveCard.
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    stopService(new Intent(CompassMenuActivity.this, CompassService.class));
                }
            });
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
项目:PTVGlass    文件:MenuActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection.
    switch (item.getItemId()) {
        case R.id.stop:
            // Stop the service at the end of the message queue for proper options menu
            // animation. This is only needed when starting a new Activity or stopping a Service
            // that published a LiveCard.
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    stopService(new Intent(MenuActivity.this, OpenGlService.class));
                }
            });
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
项目:PTVGlass    文件:MenuActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection.
    switch (item.getItemId()) {
        case R.id.stop:
            // Stop the service at the end of the message queue for proper options menu
            // animation. This is only needed when starting a new Activity or stopping a Service
            // that published a LiveCard.
            post(new Runnable() {

                @Override
                public void run() {
                    stopService(new Intent(MenuActivity.this, StopwatchService.class));
                }
            });
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
项目:gdk-stopwatch-sample    文件:MenuActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection.
    switch (item.getItemId()) {
        case R.id.stop:
            // Stop the service at the end of the message queue for proper options menu
            // animation. This is only needed when starting a new Activity or stopping a Service
            // that published a LiveCard.
            post(new Runnable() {

                @Override
                public void run() {
                    stopService(new Intent(MenuActivity.this, StopwatchService.class));
                }
            });
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
项目:javapoet    文件:TypeSpecTest.java   
@Test public void varargs() throws Exception {
  TypeSpec taqueria = TypeSpec.classBuilder("Taqueria")
      .addMethod(MethodSpec.methodBuilder("prepare")
          .addParameter(int.class, "workers")
          .addParameter(Runnable[].class, "jobs")
          .varargs()
          .build())
      .build();
  assertThat(toString(taqueria)).isEqualTo(""
      + "package com.squareup.tacos;\n"
      + "\n"
      + "import java.lang.Runnable;\n"
      + "\n"
      + "class Taqueria {\n"
      + "  void prepare(int workers, Runnable... jobs) {\n"
      + "  }\n"
      + "}\n");
}
项目:consulo-java    文件:ManyClasses.java   
public void foo() {
  Runnable r = new Runnable() {
    @Override
    public void run() {
      Comparable<Integer> c = new Comparable<Integer>() {
        @Override
        public int compareTo(Integer o) {
          return 0;
        }
      };
    }
  };

  class FooLocal {
    Runnable r = new Runnable() {
      @Override
      public void run() {
      }
    };
  }
}
项目:Project-Sarica-v3    文件:ThreadOwner.java   
public Runnable next()
{
    synchronized (tasks)
    {
        if (tasks.isEmpty())
            return null;
        return tasks.removeFirst();
    }
}
项目:react-native-incall-manager    文件:InCallProximityManager.java   
private InCallProximityManager(Context context, final InCallManagerModule inCallManager) {
    Log.d(TAG, "InCallProximityManager");
    checkProximitySupport(context);
    if (proximitySupported) {
        proximitySensor = AppRTCProximitySensor.create(context,
            new Runnable() {
                @Override
                public void run() {
                    inCallManager.onProximitySensorChangedState(proximitySensor.sensorReportsNearState());               
                }
            }
        );
    }
}
项目:executordecorator    文件:VoidMethodWithParameterDecorator.java   
@Override
public void method(final int i) {
    executor.execute(new Runnable() {

        @Override()
        public void run() {
            decorated.method(i);
        }
    });
}
项目:executordecorator    文件:InheritanceDecorator.java   
@Override
public void mother() {
    executor.execute(new Runnable() {

        @Override()
        public void run() {
            decorated.mother();
        }
    });
}
项目:executordecorator    文件:InheritanceDecorator.java   
@Override
public void child() {
    executor.execute(new Runnable() {

        @Override()
        public void run() {
            decorated.child();
        }
    });
}
项目:executordecorator    文件:VoidMethodWithParametersDecorator.java   
@Override
public void method(final int i, final Long l) {
    executor.execute(new Runnable() {

        @Override()
        public void run() {
            decorated.method(i, l);
        }
    });
}
项目:executordecorator    文件:VoidMethodDecorator.java   
@Override
public void method() {
    executor.execute(new Runnable() {

        @Override()
        public void run() {
            decorated.method();
        }
    });
}
项目:executordecorator    文件:VoidMethodDecorator.java   
@Override
public void method() {
    executor.execute(new Runnable() {

        @Override()
        public void run() {
            final VoidMethodModule.VoidMethod decorated = weakReference.get();
            if (decorated != null) {
                decorated.method();
            }
        }
    });
}
项目:executordecorator    文件:VoidMethodDecorator.java   
@Override
public void method() {
    executor.execute(new Runnable() {

        @Override()
        public void run() {
            if (decorated != null) {
                decorated.method();
            }
        }
    });
}
项目:iBioSim    文件:TransitionsPanel.java   
@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("comboBoxChanged")) {

    }
    Object o = e.getSource();
    if (o instanceof Runnable) {
        ((Runnable) o).run();
    }
}
项目:react-native-background-timer    文件:BackgroundTimerModule.java   
@ReactMethod
public void start(final int delay) {
    handler = new Handler();
    runnable = new Runnable() {
        @Override
        public void run() {
            sendEvent(reactContext, "backgroundTimer");
        }
    };

    handler.post(runnable);
}
项目:react-native-background-timer    文件:BackgroundTimerModule.java   
@ReactMethod
public void setTimeout(final int id, final int timeout) {
    Handler handler = new Handler();
    handler.postDelayed(new Runnable(){
        @Override
        public void run(){
            if (getReactApplicationContext().hasActiveCatalystInstance()) {
                getReactApplicationContext()
                    .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                    .emit("backgroundTimer.timeout", id);
            }
       }
    }, timeout);
}
项目:throwable-interfaces    文件:RunnableWithThrowable.java   
/**
 * @return An interface that completely ignores exceptions. Consider using this method withLogging() as well.
 */
default Runnable thatThrowsNothing() {
    return () -> {
        try {
            runWithThrowable();
        } catch(Throwable ignored) {}
    };
}
项目:throwable-interfaces    文件:RunnableWithThrowable.java   
/**
 * @throws E if an exception E has been thrown, it is rethrown by this method
 * @return An interface that is only returned if no exception has been thrown.
 */
default Runnable thatUnsafelyThrowsUnchecked() throws E {
    return () -> {
        try {
            runWithThrowable();
        } catch(final Throwable throwable) {
            SuppressedException.throwUnsafelyAsUnchecked(throwable);
        }
    };
}
项目:intellij-ce-playground    文件:formatOptimizeVcsChanges_before.java   
public static void main(String[] args) {
  Runnable runnable = new Runnable() {
      @Override
      public void run() {
          Set<String> test = new LinkedHashSet<String>();
          if (test.contains("AA")) {
            if (test.contains("AS")) {
              System.out.println("AAAA!");
            }
          }
      }
  };

  runnable.run();
}
项目:intellij-ce-playground    文件:simpleFileNewBlockOffsetDetection.java   
public void test() {
  run(new Runnable() {
      @Override
      public void run() {
        System.out.println("AAAA");
      }
  });
}
项目:IReS-Platform    文件:Main.java   
private static void addShutdownHook() {
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Logger.getLogger(Main.class.getName()).info("Server is shutting down");
                ServerStaticComponents.server.stop();
            } catch (Exception ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }));

}