我对javakilim框架还比较陌生,并学习了一些代码,但我对编译时/运行时编织一无所知,需要一些帮助才能让代码正常工作。我使用了kilim-2.0.2、asm-7.0和javajdk1.8
############################################################
Task class com.kulan.kilim.Processor has either not been woven or the classpath is incorrect
############################################################
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Unknown Source)
at kilim.Task.errNotWoven(Task.java:306)
at kilim.Task.execute(Task.java:483)
at kilim.Task.run(Task.java:550)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我的代码
public class KilimTest {
private static final int processorCount=Runtime.getRuntime().availableProcessors()+1;
private static CountDownLatch latch=null;
private static Random random=new Random();
private static int executeTimes=processorCount*100;
public static void main(String[] args) throws Exception{
//Weaver.main(args);
long beginTime=System.currentTimeMillis();
latch=new CountDownLatch(executeTimes*processorCount);
for (int j = 0; j < processorCount; j++) {
new Thread(new NotifyProcessorTask()).start();
}
latch.await();
long endTime=System.currentTimeMillis();
System.out.println("execute time: "+(endTime-beginTime)+" ms");
System.exit(0);
}
static class NotifyProcessorTask implements Runnable{
public void run() {
String threadName=Thread.currentThread().getName();
for (int i = 0; i < executeTimes; i++) {
Mailbox<String> messages=new Mailbox<String>();
new Processor(messages,latch).start();
messages.putnb(threadName+String.valueOf(i));
try {
Thread.sleep(random.nextInt(5));
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
public class Processor extends Task{
private Random random=new Random();
private Mailbox<String> messages;
private CountDownLatch latch;
public Processor(Mailbox<String> messages,CountDownLatch latch){
this.messages=messages;
this.latch=latch;
}
public void execute() throws Pausable, Exception {
messages.get();
int counter=0;
while(counter<100){
List<String> list=new ArrayList<String>();
for (int i = 0; i < 1000; i++) {
list.add(String.valueOf(i));
}
counter++;
Task.sleep(random.nextInt(2));
}
latch.countDown();
Task.exit(0);
}
}
暂无答案!
目前还没有任何答案,快来回答吧!