紧急求助,关于ScheduledThreadPoolExecutor类,线程池相关
今天遇到一个面试题,搞不定啊,大侠帮帮忙:
编写代码控制一个点a在10秒以后以直线方式从b位置飞向c位置(每秒向前步进一次)。
完成 run 中的代码
class Point implements java.lang.Runnable
{
float x;
float y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println(x+","+y);
}
static Point a = new Point(0, 0);
static Point b = new Point(127, 431);
public static void main(String[] args)
{
java.util.concurrent.ScheduledThreadPoolExecutor
scheduled = new java.util.concurrent.ScheduledThreadPoolExecutor(10);
scheduled.scheduleAtFixedRate(
a, 1, 1, java.util.concurrent.TimeUnit.SECONDS);
}
}