java halt_Java Runtime halt()方法

Java Runtime halt()方法

java.lang.Runtime.halt(int status) 方法强行终止当前正在运行的Java虚拟机。此方法从不正常返回。这个方法应该非常谨慎。不同的是退出的方法,这种方法不会导致关机钩启动,并不会运行未调用的终结,如果最后确定的退出已启用。如果关机顺序已经启动,则此方法不会等待任何正在运行关闭钩子或终结器来完成他们的工作。

1 语法

public void halt(int status)

2 参数

status :终止状态。按照惯例,非零的状态码表示异常终止。如果exit(等同于System.exit)方法已经被调用则此状态码将覆盖传递给该方法的状态代码。

3 返回值

此方法不返回任何值。

4 示例

package com.yiidian;

/**

* 一点教程网: http://www.yiidian.com

*/

/**

* Java Runtime halt()方法

*/

public class RuntimeDemo {

public static void main(String[] args) {

// print when the program starts

System.out.println("Program starting...");

// halt this process

Runtime.getRuntime().halt(0);

// print a string, just to see if it process is halted

System.out.println("Process is still running.");

}

}

输出结果为:

Program starting...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个示例的Java程序,可以方便地生成A表的假数据: ```java import java.util.Date; import java.util.Random; public class DataGenerator { private static final int NUM_ROWS = 100; // 生成100行数据 private static final String[] CUST_NAMES = {"张三", "李四", "王五", "赵六", "钱七", "孙八", "周九", "吴十"}; private static final String[] QUALIFICATION_NAMES = {"工商注册证", "税务登记证", "组织机构代码证", "营业执照", "法人身份证"}; private static final String[] CUST_FROMS = {"淘宝", "天猫", "京东", "苏宁易购", "唯品会", "拼多多"}; private static final String[] ALICOM_INDUSTRIES = {"电商", "餐饮", "旅游", "教育", "医疗", "房地产"}; private static final String[] ALICOM_CUST_TYPES = {"企业", "个体工商户", "个人"}; private static final String[] REMARKS = {"无", "一般", "重要", "紧急"}; private static final String[] ORGANIZATION_CODES = {"123456", "654321", "234567", "876543", "345678", "987654"}; private static final Random random = new Random(); public static void main(String[] args) { for (int i = 0; i < NUM_ROWS; i++) { Date now = new Date(); Date gmtCreate = new Date(now.getTime() - random.nextInt(1000000) * 1000L); // 随机生成过去的时间 Date gmtModified = new Date(now.getTime() - random.nextInt(10000) * 1000L); // 随机生成最近的时间 long qualificationId = random.nextInt(100000) + 1; // 从1到100000随机生成qualification_id String partnerId = String.format("%06d", random.nextInt(1000000)); // 随机生成6位数字的partner_id String custName = CUST_NAMES[random.nextInt(CUST_NAMES.length)]; String qualificationName = QUALIFICATION_NAMES[random.nextInt(QUALIFICATION_NAMES.length)]; String custFrom = CUST_FROMS[random.nextInt(CUST_FROMS.length)]; String custId = String.format("%012d", random.nextInt(1000000000000L)); // 随机生成12位数字的cust_id String aliUid = String.format("%08d", random.nextInt(100000000)); // 随机生成8位数字的ali_uid String aliAccount = "ali_" + String.format("%06d", random.nextInt(1000000)); // 随机生成ali_后面跟6位数字的ali_account Date aliCreateTime = new Date(now.getTime() - random.nextInt(1000000) * 1000L); // 随机生成过去的时间 String aliCid = String.format("%08d", random.nextInt(100000000)); // 随机生成8位数字的ali_cid String alicomHaltStatus = random.nextInt(2) == 0 ? "正常" : "停用"; // 随机生成alicon_halt_status String cbmWorkId = "cbm_" + String.format("%06d", random.nextInt(1000000)); // 随机生成cbm_后面跟6位数字的cbm_work_id String anyParam = "param_" + String.format("%06d", random.nextInt(1000000)); // 随机生成param_后面跟6位数字的any_param int illegalCaseCount = random.nextInt(10); // 随机生成0到9之间的数字 String smsHaltStatus = random.nextInt(2) == 0 ? "正常" : "停用"; // 随机生成sms_halt_status String voiceHaltStatus = random.nextInt(2) == 0 ? "正常" : "停用"; // 随机生成voice_halt_status Date alicomCreateTime = new Date(now.getTime() - random.nextInt(1000000) * 1000L); // 随机生成过去的时间 String alicomIndustry = ALICOM_INDUSTRIES[random.nextInt(ALICOM_INDUSTRIES.length)]; String alicomCustType = ALICOM_CUST_TYPES[random.nextInt(ALICOM_CUST_TYPES.length)]; String remark = REMARKS[random.nextInt(REMARKS.length)]; String freeSignFlag = random.nextInt(2) == 0 ? "Y" : "N"; // 随机生成Y或N的free_sign_flag String organizationCode = ORGANIZATION_CODES[random.nextInt(ORGANIZATION_CODES.length)]; String dataType = "A表"; int smsIllegalCount = random.nextInt(10); // 随机生成0到9之间的数字 int voiceIllegalCount = random.nextInt(10); // 随机生成0到9之间的数字 String activeFlag = random.nextInt(2) == 0 ? "Y" : "N"; // 随机生成Y或N的active_flag System.out.printf("%s, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %s\n", gmtCreate, gmtModified, qualificationId, partnerId, custName, qualificationName, custFrom, custId, aliUid, aliAccount, aliCreateTime, aliCid, alicomHaltStatus, cbmWorkId, anyParam, illegalCaseCount, smsHaltStatus, voiceHaltStatus, alicomCreateTime, alicomIndustry, alicomCustType, remark, freeSignFlag, organizationCode, dataType, smsIllegalCount, voiceIllegalCount, activeFlag); } } } ``` 该程序使用Java的Random类生成假数据,其中包括: - gmt_create和gmt_modified字段:随机生成过去的时间和最近的时间 - qualification_id字段:从1到100000随机生成qualification_id - partner_id字段:随机生成6位数字的partner_id - cust_name字段:从预定义的名字列表中随机选择 - qualification_name字段:从预定义的资质名称列表中随机选择 - cust_from字段:从预定义的来源列表中随机选择 - cust_id字段:随机生成12位数字的cust_id - ali_uid字段:随机生成8位数字的ali_uid - ali_account字段:随机生成ali_后面跟6位数字的ali_account - ali_create_time字段:随机生成过去的时间 - ali_cid字段:随机生成8位数字的ali_cid - alicom_halt_status字段:随机生成"正常"或"停用" - cbm_work_id字段:随机生成cbm_后面跟6位数字的cbm_work_id - any_param字段:随机生成param_后面跟6位数字的any_param - illegal_case_count字段:随机生成0到9之间的数字 - sms_halt_status字段:随机生成"正常"或"停用" - voice_halt_status字段:随机生成"正常"或"停用" - alicom_create_time字段:随机生成过去的时间 - alicom_industry字段:从预定义的行业列表中随机选择 - alicom_cust_type字段:从预定义的客户类型列表中随机选择 - remark字段:从预定义的备注列表中随机选择 - free_sign_flag字段:随机生成"Y"或"N" - organization_code字段:从预定义的组织机构代码列表中随机选择 - data_type字段:固定为"A表" - sms_illegal_count字段:随机生成0到9之间的数字 - voice_illegal_count字段:随机生成0到9之间的数字 - active_flag字段:随机生成"Y"或"N" 你可以根据自己的需求修改或扩展这个程序来生成更多的假数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值