org.openide.util.Task.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.openide.util.Task.<init>()方法的一些代码示例,展示了Task.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.<init>()方法的具体详情如下:
包路径:org.openide.util.Task
类名称:Task
方法名:<init>

Task.<init>介绍

[英]Constructor for subclasses that wants to control whole execution itself.
[中]用于希望控制整个执行本身的子类的构造函数。

代码示例

代码示例来源:origin: stackoverflow.com

service.scheduleAtFixedRate(new Task(), 0, 1000, TimeUnit.MILLISECONDS);

代码示例来源:origin: stackoverflow.com

float delay = 1; // seconds

Timer.schedule(new Task(){
  @Override
  public void run() {
    // Do your work
  }
}, delay);

代码示例来源:origin: stackoverflow.com

ExecutorService executor = Executors.newSingleThreadExecutor();
executor.invokeAll(Arrays.asList(new Task()), 10, TimeUnit.MINUTES); // Timeout of 10 minutes.
executor.shutdown();

代码示例来源:origin: stackoverflow.com

Task t = new Task(i);
executor.execute(t);

代码示例来源:origin: stackoverflow.com

for (int i = 1; i <= 200; i++){
  Task t = new Task();
  FL.add(ES.submit(t));
}

代码示例来源:origin: stackoverflow.com

@WebListener
public class Config implements ServletContextListener {

  private ScheduledExecutorService scheduler;

  @Override
  public void contextInitialized(ServletContextEvent event) {
    scheduler = Executors.newSingleThreadScheduledExecutor();
    scheduler.scheduleAtFixedRate(new Task(), 0, 1, TimeUnit.MINUTES); // Schedule to run every minute.
  }

  @Override
  public void contextDestroyed(ServletContextEvent event) {
    scheduler.shutdown(); // Important! This stops the thread.
  }

}

代码示例来源:origin: stackoverflow.com

ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
List<Future<String>> results = executor.invokeAll(Arrays.asList(new Task()), 1, TimeUnit.SECONDS); // Timeout of 1 second.
for (Future<String> result : results) {
  if (!result.isCancelled()) {
    System.out.println(result.get()); // Won't be printed as the "actual" processing took 2 seconds.
  } else {
    System.out.println("Task timed out.");
  }
}
executor.shutdown();

代码示例来源:origin: stackoverflow.com

var start, Task;

start = function () {
 var Task; // (undefined)
 Task = new Task();
};

Task = function () {
  console.log('work!');
};

start();

代码示例来源:origin: stackoverflow.com

public class TaskHelper
{
  private Task task;

  public TaskHelper() {
    task = new Task();
  }

  // expose methods to delegate functionality to the private member
}

代码示例来源:origin: stackoverflow.com

private float delay = 2; //In seconds this time

//At some point you set the timer
Timer.schedule(new Task(){
  @Override
  public void run() {
    // Do something
  }
}, delay);

代码示例来源:origin: stackoverflow.com

float delay = 1; // seconds

Timer.schedule(new Task(){
  @Override
  public void run() {
    // Do your work
  }
}, delay);

代码示例来源:origin: stackoverflow.com

private ArrayList<Task> array_task = new ArrayList<Task>();
private void callTask() {

Task task = new Task() {

 @Override
 protected void doInBackground(String... params) {

 }
 }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
      string1,string2 );
array_task.add(task);

 }

代码示例来源:origin: stackoverflow.com

ExecutorService exec = Executors.newFixedThreadPool(10);

for(int i = 0; i < 10; i++) {
  exec.submit(new Task(i));
}    

// later

for(int i = 0; i < 10; i++) {
  exec.submit(new Task(i));
}    

exec.shutdown(); // etc.

代码示例来源:origin: stackoverflow.com

map.put("someString", new Task() {
  @Override
  public void doSomething() {
    System.out.println("foo");
  }
});
map.put("someOtherString", new Task() {
  @Override
  public void doSomething() {
    System.out.println("bar");
  }
});

代码示例来源:origin: stackoverflow.com

public class Config implements ServletContextListener {

  private ScheduledExecutorService scheduler;

  public void contextInitialized(ServletContextEvent event) {
    scheduler = Executors.newSingleThreadScheduledExecutor();
    scheduler.scheduleAtFixedRate(new Task(), millisToNext1000, 1, TimeUnit.DAYS);
  }

  public void contextDestroyed(ServletContextEvent event) {
    scheduler.shutdown();
  }

}

代码示例来源:origin: stackoverflow.com

private void test() {
   ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
   ScheduledFuture<?> future =  exec.scheduleAtFixedRate(new Task(), 0, 5, TimeUnit.MINUTES);
   //if you want to cancel the task
   //boolean is if you want to interrupt while running
   future.cancel(true);
 }

代码示例来源:origin: stackoverflow.com

int procs = Runtime.getRuntime().availableProcessors();
ExecutorService es = Executors.newFixedThreadPool(procs);

List<Future<TaskResult>> results = new ArrayList();
for(int i=0;i<tasks;i++)
  results.add(es.submit(new Task(i)));
for(Future<TaskResult> future:results)
  reduce(future);

代码示例来源:origin: stackoverflow.com

Scanner scan = new Scanner(new File("myFile"));

ArrayList<Task> output = new ArrayList<Task>();

while (scan.hasNext()) {
  String s = scan.next();
  int num1 = scan.nextInt();
  int num2 = scan.nextInt();
  output.add(new Task(s, num1, num2));
}

代码示例来源:origin: stackoverflow.com

final ExecutorService executorService = Executors.newCachedThreadPool();
final ExecutorCompletionService<String> completionService = 
      new ExecutorCompletionService<String>(executorService);
for (int i = 0; i < 10; ++i) {
  completionService.submit(new Task());
}
completionService.take().get();

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
  Task myTask = new Task();
  myTask.setDate("02\\03\\20");
  System.out.println(myTask.dateIsValid());
  Task myTask2 = new Task();
  myTask2.setDate("23\\45\\6001");
  System.out.println(myTask2.dateIsValid());
}

相关文章