start 和 run 用法
时间: 2024-05-16 21:14:37 浏览: 22
`start` 和 `run` 都是用于执行程序的命令,但它们的使用场景略有不同。
`start` 命令通常用于启动一个新的进程,可以在后台运行并立即返回命令提示符。例如,使用 `start` 命令启动一个应用程序,可以像这样:
```
start notepad.exe
```
这将启动记事本应用程序,并立即返回命令提示符,不会阻塞你的终端窗口。
`run` 命令通常用于在当前进程中执行一个命令,通常是一个脚本或批处理文件。例如,使用 `run` 命令运行一个 Python 脚本,可以像这样:
```
python script.py
```
这将在当前命令提示符窗口中运行 Python 脚本,并在脚本执行完成后返回命令提示符。
总之,`start` 用于启动新的进程,而 `run` 用于在当前进程中执行命令。
相关问题
java中start和run方法区别
Java中的start()和run()方法有以下区别:
1. start()方法用于启动一个新的线程,而run()方法只是普通的方法调用。
2. start()方法会在新的线程中执行run()方法,而run()方法只会在当前线程中执行。
3. start()方法会立即返回,而不会等待run()方法执行完毕,而run()方法会一直执行直到结束。
4. start()方法只能被调用一次,而run()方法可以被多次调用。
总之,start()方法是用于启动新线程的,而run()方法只是普通的方法调用。在使用多线程时,应该使用start()方法来启动新线程,而不是直接调用run()方法。
start方法和run方法的区别
start方法和run方法的区别在于,start方法会启动一个新的线程来执行run方法中的代码,而run方法则是在当前线程中直接执行。如果直接调用run方法,那么就不会启动新的线程,而是在当前线程中执行run方法中的代码。因此,如果需要启动新的线程来执行代码,就应该使用start方法。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)