我不明白为什么Java会在此代码中抛出来自subject的异常.有人可以解释一下吗?
class Wait implements Runnable
{
public void run() {
synchronized (Object.class) {
try {
while(true) {
System.out.println("Before wait()");
wait();
System.out.println("After wait()");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public class ObjectMethodInConcurency
{
public static void main(String[] args) {
Wait w = new Wait();
(new Thread(w)).start();
}
}
Run Code Online (Sandbox Code Playgroud) 我的 gdtools 包有问题。我想从源代码安装它,但不幸的是我无法在 Linux 机器上安装任何额外的库。我正在做的就是解决这个问题,它是在安装时包含软件包:
install.packages(repos = c("http://localhost.net/cran"), type = "source", pkgs = c('gdtools'), configure.vars = c("INCLUDE_DIR=/extra/gdtools/windows/cairo-1.15.10/include/cairo"))
Run Code Online (Sandbox Code Playgroud)
这让我可以更进一步。但是我需要再包含一个目录,指向 freetype 库:/extra/gdtools/windows/cairo-1.15.10/include/freetype2/freetype
但是当我尝试将其添加到命令时它不起作用。我尝试过很多方法,例如它不起作用:
install.packages(repos = c("http://localhost.net/cran"), type = "source", pkgs = c('gdtools'), configure.vars = c("INCLUDE_DIR=/extra/gdtools/windows/cairo-1.15.10/include/cairo /extra/gdtools/windows/cairo-1.15.10/include/freetype2/freetype"))
Run Code Online (Sandbox Code Playgroud)
有人可以帮我怎么做吗?我也从 R CMD 级别尝试过。任何解决方案对我来说都是可以接受的。
我有简单的Spring控制器与映射:
@Controller
public class HomeController {
@RequestMapping(value = "/home", method = RequestMethod.GET)
public String home(HttpSession session, HttpServletRequest request, HttpServletResponse response, Model Principal principal) {
...
return "home";
}
}
Run Code Online (Sandbox Code Playgroud)
它捕获是很自然的http://localhost:18080/XXX/home,但为什么它会捕获像http://localhost:18080/XXX/home.error或http://localhost:18080/XXX/home.qwe123.234等等的链接.我没有为home.error或home.qwe123.234等设置映射.我只在我的控制器中映射.如何阻止控制器匹配?
我知道三种创建线程的方法,Java中的任务.在求职面试中,有人问我是否有可能以其他方式在Java中创建线程.有可能吗?如果是,请举一些例子.
我需要对列之一生成的序列求和.我这样做了:
test <- tibble::tibble(
x = c(1,2,3)
)
test %>% dplyr::mutate(., s = plyr::aaply(x, .margins = 1, .fun = function(x_i){sum(seq(x_i))}))
Run Code Online (Sandbox Code Playgroud)
有更清洁的方法吗?是否有一些帮助函数,构造允许我减少这个:
plyr::aaply(x, .margins = 1, .fun = function(x_i){sum(seq(x_i))})
Run Code Online (Sandbox Code Playgroud)
我正在寻找一个通用的解决方案,这里sum和seq只是一个例子.也许真正的问题是我确实想要在元素上执行函数而不是所有向量.
这是我的真实案例:
test <- tibble::tibble(
x = c(1,2,3),
y = c(0.5,1,1.5)
)
d <- c(1.23, 0.99, 2.18)
test %>% mutate(., s = (function(x, y) {
dn <- dnorm(x = d, mean = x, sd = y)
s <- sum(dn)
s
})(x,y))
test %>% plyr::ddply(., c("x","y"), .fun = function(row) {
dn <- dnorm(x …Run Code Online (Sandbox Code Playgroud)