runnable

    4热度

    2回答

    我想每5秒运行一段代码。我在处理程序中遇到了麻烦。 Kotlin如何做到这一点?这是我到目前为止。还要注意,变量Timer_Preview是一个Handler。

    0热度

    1回答

    我有一个具有闪烁光标的自定义视图。我使用Handler闪烁光标并在延迟500毫秒后发布Runnable。 当视图处于活动状态时,我想通过删除处理程序上的回调来停止闪烁。不过,我注意到,当我切换到另一个应用程序时,处理程序/ runnable继续执行,即日志表示它仍在闪烁。 如果我有看法的控制,我只想做一些像this @Override protected void onPause() {

    0热度

    1回答

    我需要制作一个带有一些参数的可运行HashMap。 (我编码一个游戏,我想:“当一名球员进入一个特定的命令它的运行与ARGS一个比空隙,缓存在我的HashMap中。”) 的代码将是(也许)比我更明确: 1 =>制作地图的命令列表中,每个键应该运行: - “myVoidWithArgs(ARG1,ARG2)” - “myOtherVoidWithArgs(arg1,arg2)” -etc。 (ARG

    2热度

    1回答

    我一直在研究由人编写的例子Java代码,面对下面的代码片段: Runnable runnable =() -> System.out.println("Thread name: " + Thread.currentThread().getName()); Executor executor; executor = Runnable::run; executor.execute(runna

    0热度

    1回答

    我试图找到一种方法让一个线程运行2秒,另一个运行3秒。我正在使用以下可运行的代码: private Runnable setLocation, checkWriteAttempt; { setLocation = new Runnable() { @Override public void run() { // Get Location

    0热度

    2回答

    我现在正在学习Runnable,并且对我发现的代码以及它的运行方式有点困惑。 j = 0; public Runnable test = new Runnable() { @Override public void run() { if (j <= 4) { //this is an if statement. shouldn't it run only onc

    0热度

    2回答

    我想在执行new Thread的行时开始一个新的线程。我这样做: new Thread (new Runnable() { @Override public void run() { ..... } }).start(); //other code continues here 当代码来到新的线程行它跳转到执行其他代码。为什么?

    -2热度

    2回答

    我想为报警应用程序创建多个Runnable对象,它将在用户指定的时间内执行任务。 我尝试做内环路这样的: ScheduledExecutorService wait; List<Runnable> listens = new ArrayList<>(); int i; private void playAlarmOnInit(){ wait = Executors.newScheduled

    1热度

    2回答

    我在这里有点新。 所以基本上,我正在制作一个应用程序,显示在一定区域和我的xml代码中可用的餐厅我有多个TextViews通知餐馆是否打开或关闭。 我试图在onCreate方法中获取当前的日期和小时,并更改textView(如下所示)。 TextView restaurant = (TextView) findViewById (R.id.openTag); int hour = new Tim

    1热度

    1回答

    我在这里阅读了许多线程,讨论如何在运行时获取视图大小,但没有解决方案为我工作。 GameScreen.java public class GameScreen extends AppCompatActivity{ // Declare an instance of SnakeView GameView snakeView; SurfaceHolder surface; @Overri