gpt4 book ai didi

java - 更改方法的参数

转载 作者:行者123 更新时间:2023-12-01 18:15:29 31 4
gpt4 key购买 nike

我是java编程新手,我希望我选择了正确的标题。首先是我的代码:

public class main 
{

public static void main(String args[])
{

SysOutSleep sos = new SysOutSleep("Test", 450, 3 );//set the value

Thread t = new Thread(sos);

t.start();

//here i want to change the parameters from sos
//they should be something like that ("Test2", 390, 1)

//and after that i start the thread again with the new parameters

t.start();
}

}

那么我该如何更改它们,提前谢谢您:)

最佳答案

您不能两次启动同一个 Thread 实例,这意味着您必须创建一个新的 Thread :

SysOutSleep sos = new SysOutSleep("Test", 450, 3);
Thread t = new Thread(sos);
t.start();

sos = new SysOutSleep("Test2", 390, 1);
t = new Thread(sos);
t.start();

关于java - 更改方法的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29842142/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com