shutdown

The definitive code that prevents a c# console app from exiting [until custom cleanup code has completed]

瘦欲@ 提交于 2019-12-21 21:36:52
问题 Can we work together to come up with something that works for control-c, control-break, log off, window X button pressed, etc? Here is what I have so far: class Program { private static ConsoleEventHandlerDelegate consoleHandler; delegate bool ConsoleEventHandlerDelegate(CtrlTypes eventCode); static void Main(string[] args) { consoleHandler = new ConsoleEventHandlerDelegate(ConsoleCtrlCheck); SetConsoleCtrlHandler(consoleHandler, true); System.Diagnostics.Process.GetCurrentProcess().Exited +=

java线程池

安稳与你 提交于 2019-12-21 03:51:08
corePoolSize :线程池的核心池大小,在创建线程池之后,线程池默认没有任何线程。 当有任务过来的时候才会去创建创建线程执行任务。换个说法,线程池创建之后,线程池中的线程数为0,当任务过来就会创建一个线程去执行,直到线程数达到corePoolSize 之后,就会被到达的任务放在队列中。(注意是到达的任务)。换句更精炼的话:corePoolSize 表示允许线程池中允许同时运行的最大线程数。 如果执行了线程池的prestartAllCoreThreads()方法,线程池会提前创建并启动所有核心线程。 maximumPoolSize :线程池允许的最大线程数,他表示最大能创建多少个线程。maximumPoolSize肯定是大于等于corePoolSize。 keepAliveTime :表示线程没有任务时最多保持多久然后停止。默认情况下,只有线程池中线程数大于corePoolSize 时,keepAliveTime 才会起作用。换句话说,当线程池中的线程数大于corePoolSize,并且一个线程空闲时间达到了keepAliveTime,那么就是shutdown。 Unit:keepAliveTime 的单位。 workQueue :一个阻塞队列,用来存储等待执行的任务,当线程池中的线程数超过它的corePoolSize的时候,线程会进入阻塞队列进行阻塞等待

Linux CentOS7基础操作

时光总嘲笑我的痴心妄想 提交于 2019-12-20 23:47:20
目录 1、基础内容 常用单词: 设置从不锁屏: Linux终端: shell提示符: 目录文件颜色: 2、基本命令操作 ls命令: cd命令: pwd命令: 3、时间 查看系统和bios时间: 修改时间: 4、帮助 查看帮助信息: 两个查看命令使用方法的网站: 5、关机和重启 关机: 重启: 6、init 概念介绍: 命令: 7、启动级别设置 1、基础内容 常用单词: terminal:终端 network-scripts:网络脚本 passwd:密码文件 nologin:禁止登陆 shutdown:关机 poweroff:关机 reboot:重启 grep:过滤 localhost:本机 useradd:添加用户 设置从不锁屏: step 1:点击桌面右上角设置按钮(如下图) step 2:在新弹出的对话框中点击Power选项(如下图) step 3:在节电-空白屏幕处选择从不(如下图) Linux终端: (1)tty控制台终端 ctrl+alt+F1~F6:切换控制台终端 alt+F1:回到图形化终端 (2)pts虚拟终端 ctrl+shift+t:新建终端 ctrl+shift++:放大字体 ctrl+-:缩小字体 alt+num:切换终端 alt+F4:关闭终端 ctrl+l:清屏 ctrl+c:取消命令 ctrl+a:光标移动至行首 ctrl+e:光标移动至行尾 ctrl

What happens when the JVM is terminated?

二次信任 提交于 2019-12-20 18:34:31
问题 What happens when the JVM is terminated with System.exit(0) or ^C or anything of that kind? I read things like "the process is just blown away" and "every single thread is stopped", but I would like to know what happens exactly. I already know there is the shutdownHook that somehow still gets executed, but what happens before the shutdownHooks are invoked and does anything happen after all these threads have finished? I would like to implement such a shutdownHook correctly and to do so I need

Send windows message to a Windows Service

社会主义新天地 提交于 2019-12-20 12:42:23
问题 Is there any tool to send (mimic) a windows message like 'WM_ENDSESSION' to a windows service? OR How can I send a windows message to a process using C#? (I know only C#) EDIT: Purpose: Basically I have to debug a windows service for fixing a bug that occurs only on system shut down. 回答1: Generally, services don't have windows (let alone message pumps) to receive a windows message. If the bug really does only happen on shutdown (as opposed to just stopping the service), it may be the case

Shutting down computer with nasm

青春壹個敷衍的年華 提交于 2019-12-20 07:26:43
问题 Is it possible to shut down or kill the power (is there a difference?) to a computer from nasm. I know you can use this to reboot: mov al, 0xFE out 0x64, al Is there an equivalent for shutting down? I am making my own 16 bit OS. 回答1: The code you have is not guaranteed to work. It relies on two facts: the OS maps the physical IO memory into the process memory space. the machine has BIOS. Neither of the two might be true. The only reliable way to reboot or shutdown the machine programatically

java swing program not closing after dispose is called on last window

一世执手 提交于 2019-12-20 04:54:15
问题 Preface: This is the first real swing program I have done. I have a swing program, where one JButton is supposed to exit the program. That button triggers this.dispose();. When i click this JButton, it does make the window completely go away, but looking at the debugger, the program itself is still running. My main method only consists of: public static void main (String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new StartupGui().setVisible(true); } }); }

电脑定时关机命令

烈酒焚心 提交于 2019-12-20 04:12:30
比如你的电脑要在22:00关机,可以选择“开始→运行”,输入“at 22:00 Shutdown -s”,这样,到了22点电脑就会出现“系统关机”对话框,默认有30秒钟的倒计时并提示你保存工作。 如果你想以倒计时的方式关机,可以输入“Shutdown.exe -s -t 3600”,这里表示60分钟后自动关机,“3600”代表60分钟。 设置好自动关机后,如果想取消的话,可以在运行中输入“shutdown -a”。 ------------------------------------------------------------------------------ Shutdown.exe的参数,每个都具有特定的用途,执行每一个都会产生不同的效果,比如“-s”就表示关闭本地计算机,“-a”表示取消关机操作,下面列出了更多参数,大家可以在Shutdown.exe中按需使用。 -f:强行关闭应用程序 -m \\计算机名:控制远程计算机 -i:显示图形用户界面,但必须是Shutdown的第一个选项 -l:注销当前用户 -r:关机并重启 -t 时间:设置关机倒计时 -c "消息内容":输入关机对话框中的消息内容(不能超127个字符) ----------------------------------------------------------------------------

Linux: Programatically shutdown or reboot computer from a user-level process

纵然是瞬间 提交于 2019-12-20 02:59:07
问题 How do I programatically trigger a system shutdown or reboot in Linux? Preferably without requiring elevated privileges. On older releases (e.g. Ubuntu 10.04) I could call HAL's org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown or Reboot methods using D-Bus. See: http://people.freedesktop.org/~dkukawka/hal-spec-git/hal-spec.html#interface-device-systempower. However HAL appears to be obsolete, and is not present in Ubuntu 12.10. What is the current best-practice for doing this? 回答1:

Linux命令总结

旧时模样 提交于 2019-12-20 02:06:45
1 vi编辑器 2 文件操作 2.1 删除文件 2.2 查看文件 2.3 创建文件夹 2.4 查看文件权限 2.5 复制文件 2.6 移动 2.7 查找文件 3 查看cpu信息 4 进程管理 5 查看日志 6 压缩与解压缩 7 网络 7.1 网络配置 7.2 网络管理netstat命令 8 查看磁盘io 9 用户 10 服务管理 11 进程管理 12 重启和关机 13 CPU和内存使用情况监控 14 安装Ubuntu 15 常用工具 15.1 Nano编辑器 15.2 安装OPENSSL Server 15.3 Telnet 15.4 wget 16 语言 1 vi编辑器 操作描述 退出命令,输入: 按esc进入命令模式 退出命令 q 退出不保存 q! 保存退出 wq 输入 a 从光标所在位置后面输入字符 I 从光标所在位置前面输入字符 删除 dd 删除行 X 删除选中的字符 换行 O 在光标所在行下面新增一行并进入输入模式 O 在光标所在行上面新增一行并进入输入模式 查找 命令模式输入 /要查找的内容 dd 删除一行 ndd 删除n行 u 撤销 yy 复制当前行 p 粘贴 参考地址: http://man.ddvip.com/soft/vieditor/vi.html 2 文件操作 2.1 删除文件 删除文件 rm [filename] 删除文件夹 rm -rf