L
Let me Think
Dear All
I'm fairly new to Java and have been attempting to get the
java.util.concurrent package to work.
I am using java version
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
Following many hours of reading the APIs and scouring the internet for
samples, have got stuck and am looking for help.
Below are files I have been creating as test files
ThreadPerTaskExecutor.java
ThreadOne.java
ThreadTwo.java
The idea is that when the method execute() in the class
ThreadPerTaskExecutor is called it will concurrently launch the code in
ThreadOne.java
ThreadTwo.java
So far
ThreadOne.java
ThreadTwo.java
Compile fine
However ThreadPerTaskExecutor.java fails to compile with the following
errors.
C:\test\ThreadPerTaskExecutor.java:5: test.ThreadPerTaskExecutor is not
abstract and does not override abstract method execute(java.lang.Runnable)
in java.util.concurrent.Executor
class ThreadPerTaskExecutor implements Executor {
^
C:\test\ThreadPerTaskExecutor.java:9: cannot find symbol
symbol : variable executer
location: class test.ThreadPerTaskExecutor
executer.execute(new test.ThreadOne());
^
C:\test\ThreadPerTaskExecutor.java:10: cannot find symbol
symbol : variable executor
location: class test.ThreadPerTaskExecutor
executor.execute(new test.ThreadTwo());
The Reason I am looking in to this is to be able to launch two or more
methods concurrently in robocode for performance reasons.
Any ideas what I have done wrong
Thanks
----------- file ThreadPerTaskExecutor.java --------
package test;
import java.util.concurrent.*;
class ThreadPerTaskExecutor implements Executor {
public void execute() {
executer.execute(new test.ThreadOne());
executor.execute(new test.ThreadTwo());
}
}
----------- file ThreadOne.java --------
package test;
import robocode.*;
public class ThreadOne {
public void run() {
System.out.println("External Thread one");
}
public void ThreadOne() {
System.out.println("External Thread Two");
}
}
----------- file ThreadTwo.java --------
package test;
import robocode.*;
public class ThreadTwo {
public void run() {
System.out.println("External Thread Two");
}
public void ThreadTwo() {
System.out.println("External Thread Two");
}
}
I'm fairly new to Java and have been attempting to get the
java.util.concurrent package to work.
I am using java version
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
Following many hours of reading the APIs and scouring the internet for
samples, have got stuck and am looking for help.
Below are files I have been creating as test files
ThreadPerTaskExecutor.java
ThreadOne.java
ThreadTwo.java
The idea is that when the method execute() in the class
ThreadPerTaskExecutor is called it will concurrently launch the code in
ThreadOne.java
ThreadTwo.java
So far
ThreadOne.java
ThreadTwo.java
Compile fine
However ThreadPerTaskExecutor.java fails to compile with the following
errors.
C:\test\ThreadPerTaskExecutor.java:5: test.ThreadPerTaskExecutor is not
abstract and does not override abstract method execute(java.lang.Runnable)
in java.util.concurrent.Executor
class ThreadPerTaskExecutor implements Executor {
^
C:\test\ThreadPerTaskExecutor.java:9: cannot find symbol
symbol : variable executer
location: class test.ThreadPerTaskExecutor
executer.execute(new test.ThreadOne());
^
C:\test\ThreadPerTaskExecutor.java:10: cannot find symbol
symbol : variable executor
location: class test.ThreadPerTaskExecutor
executor.execute(new test.ThreadTwo());
The Reason I am looking in to this is to be able to launch two or more
methods concurrently in robocode for performance reasons.
Any ideas what I have done wrong
Thanks
----------- file ThreadPerTaskExecutor.java --------
package test;
import java.util.concurrent.*;
class ThreadPerTaskExecutor implements Executor {
public void execute() {
executer.execute(new test.ThreadOne());
executor.execute(new test.ThreadTwo());
}
}
----------- file ThreadOne.java --------
package test;
import robocode.*;
public class ThreadOne {
public void run() {
System.out.println("External Thread one");
}
public void ThreadOne() {
System.out.println("External Thread Two");
}
}
----------- file ThreadTwo.java --------
package test;
import robocode.*;
public class ThreadTwo {
public void run() {
System.out.println("External Thread Two");
}
public void ThreadTwo() {
System.out.println("External Thread Two");
}
}