我使用ExecutorService在不同的线程中运行许多任务.有时,在线程池中等待的Runnable实例太多可能会导致Out of Memory问题.
我尝试编写一个阻塞作业执行器来解决它.这有什么官方解决方案吗?
例如:
BlockingJobExecutor executor = new BlockingJobExecutor(3);
for (int i = 0; i < 1000; i++) {
executor.addJob(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LogFactory.getLog(BTest.class).info("test " + System.currentTimeMillis());
}
});
}
executor.shutdown();
Run Code Online (Sandbox Code Playgroud)
这是BlockingJobExecutor类:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class BlockingJobExecutor {
AtomicInteger counter = new AtomicInteger();
ExecutorService service;
int threads;
public BlockingJobExecutor(int threads) {
if (threads < 1) {
throw new IllegalArgumentException("threads …Run Code Online (Sandbox Code Playgroud) 我有一个使用ffmpeg库的iOS应用程序,iOS应该在静态链接中编译.根据LGPLv2,我是否会发布与我的UI或其他业务逻辑相关的源代码?
我曾经使用git cvsimportcvs 服务器,并且工作正常。然而,一些非常老的项目有很多提交和大文件。它导致 cvsimport 花费很长时间检查所有提交并将它们转换为 git 格式。
我cvsimport喜欢这个:
git cvsimport -v -a -d :pserver:qrtt1@localhost:/cvs cvsroot/my_module
Run Code Online (Sandbox Code Playgroud)
是否可以在某个日期之后选择提交?
如果我有一个文件描述符(套接字 fd),如何检查该 fd 是否可用于读/写?在我的情况下,客户端已连接到服务器并且我们知道 fd。但是,服务器会断开套接字,有什么线索可以检查吗?
我从joynet cloud api服务器获取日期格式:
2012-11-20T10:26:04+00:00"
Run Code Online (Sandbox Code Playgroud)
但是,我不知道处理最后一段+00:00,我已经制作了除+00:00之外的格式
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date date = fmt.parse("2012-11-20T10:26:04");
Run Code Online (Sandbox Code Playgroud)
谢谢@Abu
我重写它以删除":",
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
String input = "2012-11-20T10:25:58+00:00";
String s1 = input.split("T")[0];
String s2 = input.split("T")[1];
String sep = null;
if (s2.contains("+")) {
sep = "+";
}
if (s2.contains("-")) {
sep = "-";
}
String s3 = s2.split("\\" + sep)[0];
String s4 = s2.split("\\" + sep)[1].replace(":", "");
String cleanDate = s1 + "T" + s3 + sep + s4;
Date date …Run Code Online (Sandbox Code Playgroud) 我创建了一个 microk8s 集群,可以通过命令列出 pod get pod:
ubuntu@ip-172-31-16-34:~$ microk8s.kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-f7867546d-mlsbm 1/1 Running 1 98m
kube-system hostpath-provisioner-65cfd8595b-l2hjz 1/1 Running 1 98m
kube-system tiller-deploy-758bcdc94f-cwbjd 1/1 Running 0 93m
seldon-system seldon-controller-manager-54955d8675-72qxn 1/1 Running 0 33m
Run Code Online (Sandbox Code Playgroud)
但是,我尝试用 ctr 列出容器,但没有显示任何内容
ubuntu@ip-172-31-16-34:~$ microk8s.ctr c ls
CONTAINER IMAGE RUNTIME
Run Code Online (Sandbox Code Playgroud)
也尝试图像列表
$ microk8s.ctr image list
REF TYPE DIGEST SIZE PLATFORMS LABELS
Run Code Online (Sandbox Code Playgroud)
没什么:P 也许我需要找到它使用的命名空间?