我想从shell脚本中调用的函数返回值.也许我错过了语法.我尝试使用全局变量.但这也行不通.代码是:
lockdir="somedir"
test() {
retval=""
if mkdir "$lockdir"
then # Directory did not exist, but it was created successfully
echo >&2 "successfully acquired lock: $lockdir"
retval="true"
else
echo >&2 "cannot acquire lock, giving up on $lockdir"
retval="false"
fi
return retval
}
retval=test()
if [ "$retval" == "true" ]
then
echo "directory not created"
else
echo "directory already created"
fi
Run Code Online (Sandbox Code Playgroud) 我是神经网络领域的新手.我已经阅读了一些关于神经网络的理论.现在我想做一些真正的编码来实现我的理论课中的神经网络研究.任何人都可以建议从哪里开始或使用哪种编程语言或任何其他细节,例如URLS等.非常感谢您的帮助
ps这篇文章可能不是真正的编程情况.但我认为这是一个了解所有专业和新手查询的好论坛
说,我有一个X具有字段值的类,即
class X implements Serializable {
private int value;
// ...
}
Run Code Online (Sandbox Code Playgroud)
此外,它没有在这里显示的getter和setter.这个类是序列化的.在反序列化中,结束同一类具有值字段,访问说明符是公共的.此外,这个类没有getter和setter.所以,我的问题是:
public class ThreadState {
public static void main(String[] args){
Thread t = new Thread(){
public void run(){
// infinite loop
while (true) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}
System.out.println("thread is running..."+Thread.currentThread().toString());
}
}
};
t.start() ;
t = null ;
while (true) {
try {
Thread.sleep(3000);
}
catch (InterruptedException e) {
}
System.out.println("thread is running..."+Thread.currentThread().toString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
线程实例t初始化为null ..仍然可以在控制台上运行并打印其详细信息.需要对此进行解释