Runnable called when a window should be closed.<p>
Reinitializes the table.<p>

@param window to be closed
@param table to be updated
@return a runnable
321917
protected static Runnable getCloseRunnable(final Window window, final CmsSessionsTable table) {

        return new Runnable() {

            public void run() {

                window.close();
                try {
                    table.ini();
                } catch (CmsException e) {
                    LOG.error("Error on reading session information", e);
                }

            }

        };
    }
85817
@Deprecated
	public void addShutdownHook(final Runnable runnable) {
		closeables.offer(new AutoCloseable() {
			@Override
			public void close() {
				runnable.run();
			}
		});
	}
802708
public static void closeThrowSqlException(Closeable closeable, String label) throws SQLException {
		if (closeable != null) {
			try {
				closeable.close();
			} catch (IOException e) {
				throw SqlExceptionUtil.create("could not close " + label, e);
			}
		}
	}
902741
@Override
  public List<Runnable> shutdownNow() {
    List<Runnable> tasks = delegate.shutdownNow();
    // we need this to break out of queue.take()
    execute(
        new Runnable() {
          @Override
          public void run() {
            // do nothing
          }
        });
    return tasks;
  }
227710
public static void execute(Runnable runnable) {
		try {
			executor.execute(runnable);
		} catch (Exception e) {
			throw new UtilException(e, "Exception when running task!");
		}
	}
188610
public StashRowIterable scan(final String table)
            throws StashNotAvailableException, TableNotStashedException {
        try {
            final StashReader stashReader = _stashReader.getLockedView();

            return new StashRowIterable() {
                @Override
                protected StashRowIterator createStashRowIterator() {
                    return stashReader.scan(table);
                }
            };
        } catch (TableNotStashedException e) {
            throw propagateTableNotStashed(e);
        }
    }
596812
private Runnable createStopTask() {
    return new Runnable() {
      @Override
      public void run() {
        try {
          // Close the ZK connection in this task will make sure if there is ZK connection created
          // after doStop() was called but before this task has been executed is also closed.
          // It is possible to happen when the following sequence happens:
          //
          // 1. session expired, hence the expired event is triggered
          // 2. The reconnect task executed. With Service.state() == RUNNING, it creates a new ZK client
          // 3. Service.stop() gets called, Service.state() changed to STOPPING
          // 4. The new ZK client created from the reconnect thread update the zooKeeper with the new one
          closeZooKeeper(zooKeeper.getAndSet(null));
          notifyStopped();
        } catch (Exception e) {
          notifyFailed(e);
        }
      }
    };
  }
1280852
public Thread newThread(Runnable runnable)
    {
        Thread thread = new Thread(runnable, nameGenerator.nextID());
        thread.setPriority(priority);
        thread.setDaemon(daemon);
        thread.setUncaughtExceptionHandler(uncaughtExceptionHandler);
        return thread;
    }
305483
void doExclusive(Runnable runnable) {

        LettuceAssert.notNull(runnable, "Runnable must not be null");

        doExclusive(() -> {
            runnable.run();
            return null;
        });
    }
595245
public static void asyncExecute(Runnable runnable) {
		if (runnable != null) {
			try {
				Para.getExecutorService().execute(runnable);
			} catch (RejectedExecutionException ex) {
				logger.warn(ex.getMessage());
				try {
					runnable.run();
				} catch (Exception e) {
					logger.error(null, e);
				}
			}
		}
	}
318299
public static <E extends Throwable> @NonNull Runnable rethrowRunnable(final @NonNull ThrowingRunnable<E> runnable) {
    return runnable;
  }
624819
@Override
  public void run() {

    LOG.entering(CLASS_NAME, "run");

    try {

      LOG.log(Level.FINE, "Subscribe event handlers");

      subscribe(StartTime.class, this.startHandler.get());
      subscribe(StopTime.class, this.stopHandler.get());
      subscribe(RuntimeStart.class, this.runtimeStartHandler.get());
      subscribe(RuntimeStop.class, this.runtimeStopHandler.get());
      subscribe(IdleClock.class, this.idleHandler.get());

      LOG.log(Level.FINE, "Initiate runtime start");
      this.handlers.onNext(new RuntimeStart(this.timer.getCurrent()));

      LOG.log(Level.FINE, "Initiate start time");
      this.handlers.onNext(new StartTime(this.timer.getCurrent()));

      while (true) {

        LOG.log(Level.FINEST, "Enter clock main loop.");

        try {

          if (this.isIdle()) {
            // Handle an idle clock event, without locking this.schedule
            this.handlers.onNext(new IdleClock(this.timer.getCurrent()));
          }

          final Time event;
          final int eventQueueLen;
          synchronized (this.schedule) {

            while (this.schedule.isEmpty()) {
              this.schedule.wait();
            }

            assert this.schedule.first() != null;

            // Wait until the first scheduled time is ready.
            // NOTE: while waiting, another alarm could be scheduled with a shorter duration
            // so the next time I go around the loop I need to revise my duration.
            while (true) {
              final long waitDuration = this.timer.getDuration(this.schedule.first());
              if (waitDuration <= 0) {
                break;
              }
              this.schedule.wait(waitDuration);
            }

            // Remove the event from the schedule and process it:
            event = this.schedule.pollFirst();

            if (event instanceof ClientAlarm) {
              --this.numClientAlarms;
              assert this.numClientAlarms >= 0;
            }

            eventQueueLen = this.numClientAlarms;
          }

          assert event != null;

          LOG.log(Level.FINER,
              "Process event: {0} Outstanding client alarms: {1}", new Object[] {event, eventQueueLen});

          if (event instanceof Alarm) {
            ((Alarm) event).run();
          } else {
            this.handlers.onNext(event);
            if (event instanceof StopTime) {
              break; // we're done.
            }
          }

        } catch (final InterruptedException expected) {
          LOG.log(Level.FINEST, "Wait interrupted; continue event loop.");
        }
      }

      this.handlers.onNext(new RuntimeStop(this.timer.getCurrent(), this.exceptionCausedStop));

    } catch (final Exception e) {

      LOG.log(Level.SEVERE, "Error in runtime clock", e);
      this.handlers.onNext(new RuntimeStop(this.timer.getCurrent(), e));

    } finally {
      LOG.log(Level.FINE, "Runtime clock exit");
    }

    LOG.exiting(CLASS_NAME, "run");
  }
889868
public Runnable wrap(Throwing.Runnable runnable) {
		return () -> {
			try {
				runnable.run();
			} catch (Throwable e) {
				handler.accept(e);
			}
		};
	}
1172951
@NonNull
  public static DeleteSelection deleteFrom(@NonNull String table) {
    return deleteFrom(CqlIdentifier.fromCql(table));
  }
665563
protected final void close() {
		if (SwingUtilities.isEventDispatchThread()) {
			closeIntern();
		} else {
			try {
				SwingUtilities.invokeAndWait(new Runnable() {
					public void run() {
						closeIntern();
					}
				});
			} catch (final Exception ex) {
				ignore();
			}
		}
	}
1286019
synchronized void removeEvents(Table table) {
        final String tName = table.getName();

        try {
            final SQLiteDatabase db = dbHelper.getWritableDatabase();
            db.delete(tName, null, null);
        } catch (final SQLiteException e) {
            getConfigLogger().verbose("Error removing all events from table " + tName + " Recreating DB");
            deleteDB();
        } finally {
            dbHelper.close();
        }
    }
741271
@Override
  public ListenableFuture<Empty> deleteTableAsync(DeleteTableRequest request) {
    return createUnaryListener(request, deleteTableRpc, request.getName()).getAsyncResult();
  }