分解使用大量资源的递归函数的最佳方法是什么
例如:
function do_a_lot(){
//a lot of code and processing is done here
//it takes a lot of execution time
if($true){
//if true we have to do all of that processing again
do_a_lot();
}
}
有没有办法让服务器只需要承受第一次执行的冲击,然后将递归分解成单独的进程?还是我在做梦?
最近我开始学习多线程技术。我尝试了以下代码:
class AThread extends Thread {
int input;
public AThread(int y) {
input=y;
}
public void compute() {
System.out.println(input*input);
}
public void run() {
compute();
}
}
public class ThreadDemo {
public static void m