mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-02 02:02:13 +08:00
kafka-manager 2.0
This commit is contained in:
3
kafka-manager-core/src/test/java/META-INF/MANIFEST.MF
Normal file
3
kafka-manager-core/src/test/java/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.xiaojukeji.kafka.manager.service;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class FutureTest {
|
||||
|
||||
@Test
|
||||
public void test() throws InterruptedException, ExecutionException {
|
||||
|
||||
FutureTask<Integer> f1 = new FutureTask<Integer>(new Callable<Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer call() throws InterruptedException {
|
||||
Thread.sleep(1000L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
FutureTask<Integer> f2 = new FutureTask<Integer>(new Callable<Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer call() throws InterruptedException {
|
||||
Thread.sleep(1000L);
|
||||
return 2;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||
|
||||
long ct = System.currentTimeMillis();
|
||||
|
||||
threadPool.submit(f1);
|
||||
threadPool.submit(f2);
|
||||
threadPool.shutdown();
|
||||
|
||||
System.out.println(f1.get() + " : " + f2.get() + " use:"
|
||||
+ (System.currentTimeMillis() - ct));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xiaojukeji.kafka.manager.service.utils;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Created by arthur on 2017/5/31.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:biz-test.xml" })
|
||||
public class SpringTestBase {
|
||||
}
|
||||
Reference in New Issue
Block a user