C - rand()工作的结果,但我在数组中得到相同的数字

时间:2016-03-02 03:27:46

标签: c random

以下是两个功能:一个用于掷骰子,另一个用于滚动统计数据。当你掷骰子时,它每次给你一个随机值,这是好的。但是当滚动一个stat时,它似乎给了我所有6次迭代的相同随机值。我想这可能是因为在每次迭代后它没有正确地重置resultStat。

以下是代码:

int Roll_Dice(int number_of_dice, int number_of_faces)
{
    int i;
    int result = 0;

    srand((unsigned) time(NULL));

    for (i = 0; i < number_of_dice; i++)
    {
        result = (rand () % number_of_faces) + 1;
    }
    return (result);
}

int Roll_Stat(int number_of_dice, int use_highest)
{
    int i, a, b;
    int numberRolled[number_of_dice];
    int resultStat = 0;

    for (i = 0; i < number_of_dice; i++)
    {
        numberRolled[i] = Roll_Dice(number_of_dice, 6);
    }
    for (a = i + 1; a < number_of_dice; a++)
    {
        if (numberRolled[i] > numberRolled[a])
        {
            b               = numberRolled[i];
            numberRolled[i] = numberRolled[a];
            numberRolled[a] = b;
        }
    }
    for (i = use_highest; i >= (number_of_dice - use_highest); i--)
    {
        resultStat += numberRolled[i];
    }

    return (resultStat);
}

1 个答案:

答案 0 :(得分:3)

由于rand只有第二个粒度,因此每次再次在同一秒内再次调用time并重新播种Roll_Dice时,rand只会有第二个粒度。

您需要在Roll_Dice之外播种随机数生成器,然后只需对其中的String[] command = { "ssh", "hddev-chost-01-01", "\"" + element + "\"" }; 进行连续调用。正如您目前所做的那样,每次都使用相同的参数调用 String element = "sqoop import -D oraoop.disabled=true -D mapred.child.java.opts='\-Djava.security.egd=file:/dev/../dev/urandom' --connect 'jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=maildude.com)(PORT=1533))(CONNECT_DATA=(SERVICE_NAME=SDA.COM)(Server=Dedicated)))' --username user --password pass --query \"select INVENTORY_ITEM_ID,ORGANIZATION_ID,LAST_UPDATE_DATE,LAST_UPDATED_BY,CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN,SUMMARY_FLAG,ENABLED_FLAG,START_DATE_ACTIVE,END_DATE_ACTIVE,DESCRIPTION,BUYER_ID,ACCOUNTING_RULE_ID,INVOICING_RULE_ID,SEGMENT1,SEGMENT2,SEGMENT3,SEGMENT4,SEGMENT5,SEGMENT6,SEGMENT7,SEGMENT8,SEGMENT9,SEGMENT10,SEGMENT11,SEGMENT12,SEGMENT13,SEGMENT14,SEGMENT15,SEGMENT16,SEGMENT17,SEGMENT18,SEGMENT19,SEGMENT20,ATTRIBUTE_CATEGORY,ATTRIBUTE1,ATTRIBUTE2,ATTRIBUTE3,ATTRIBUTE4,ATTRIBUTE5,ATTRIBUTE6,ATTRIBUTE7,ATTRIBUTE8,ATTRIBUTE9,ATTRIBUTE10,ATTRIBUTE11,ATTRIBUTE12,ATTRIBUTE13,ATTRIBUTE14,ATTRIBUTE15,PURCHASING_ITEM_FLAG,SHIPPABLE_ITEM_FLAG,CUSTOMER_ORDER_FLAG,INTERNAL_ORDER_FLAG,SERVICE_ITEM_FLAG,INVENTORY_ITEM_FLAG,ENG_ITEM_FLAG,INVENTORY_ASSET_FLAG,PURCHASING_ENABLED_FLAG,CUSTOMER_ORDER_ENABLED_FLAG,INTERNAL_ORDER_ENABLED_FLAG,SO_TRANSACTIONS_FLAG,MTL_TRANSACTIONS_ENABLED_FLAG,STOCK_ENABLED_FLAG,BOM_ENABLED_FLAG,BUILD_IN_WIP_FLAG,REVISION_QTY_CONTROL_CODE,ITEM_CATALOG_GROUP_ID,CATALOG_STATUS_FLAG,RETURNABLE_FLAG,DEFAULT_SHIPPING_ORG,COLLATERAL_FLAG,TAXABLE_FLAG,QTY_RCV_EXCEPTION_CODE,ALLOW_ITEM_DESC_UPDATE_FLAG,INSPECTION_REQUIRED_FLAG,RECEIPT_REQUIRED_FLAG,MARKET_PRICE,HAZARD_CLASS_ID,RFQ_REQUIRED_FLAG,QTY_RCV_TOLERANCE,LIST_PRICE_PER_UNIT,UN_NUMBER_ID,PRICE_TOLERANCE_PERCENT,ASSET_CATEGORY_ID,ROUNDING_FACTOR,UNIT_OF_ISSUE,ENFORCE_SHIP_TO_LOCATION_CODE,ALLOW_SUBSTITUTE_RECEIPTS_FLAG,ALLOW_UNORDERED_RECEIPTS_FLAG,ALLOW_EXPRESS_DELIVERY_FLAG,DAYS_EARLY_RECEIPT_ALLOWED,DAYS_LATE_RECEIPT_ALLOWED,RECEIPT_DAYS_EXCEPTION_CODE,RECEIVING_ROUTING_ID,INVOICE_CLOSE_TOLERANCE,RECEIVE_CLOSE_TOLERANCE,AUTO_LOT_ALPHA_PREFIX,START_AUTO_LOT_NUMBER,LOT_CONTROL_CODE,SHELF_LIFE_CODE,SHELF_LIFE_DAYS,SERIAL_NUMBER_CONTROL_CODE,START_AUTO_SERIAL_NUMBER,AUTO_SERIAL_ALPHA_PREFIX,SOURCE_TYPE,SOURCE_ORGANIZATION_ID,SOURCE_SUBINVENTORY,EXPENSE_ACCOUNT,ENCUMBRANCE_ACCOUNT,RESTRICT_SUBINVENTORIES_CODE,UNIT_WEIGHT,WEIGHT_UOM_CODE,VOLUME_UOM_CODE,UNIT_VOLUME,RESTRICT_LOCATORS_CODE,LOCATION_CONTROL_CODE,SHRINKAGE_RATE,ACCEPTABLE_EARLY_DAYS,PLANNING_TIME_FENCE_CODE,DEMAND_TIME_FENCE_CODE,LEAD_TIME_LOT_SIZE,STD_LOT_SIZE,CUM_MANUFACTURING_LEAD_TIME,OVERRUN_PERCENTAGE,MRP_CALCULATE_ATP_FLAG,ACCEPTABLE_RATE_INCREASE,ACCEPTABLE_RATE_DECREASE,CUMULATIVE_TOTAL_LEAD_TIME,PLANNING_TIME_FENCE_DAYS,DEMAND_TIME_FENCE_DAYS,END_ASSEMBLY_PEGGING_FLAG,REPETITIVE_PLANNING_FLAG,PLANNING_EXCEPTION_SET,BOM_ITEM_TYPE,PICK_COMPONENTS_FLAG,REPLENISH_TO_ORDER_FLAG,BASE_ITEM_ID,ATP_COMPONENTS_FLAG,ATP_FLAG,FIXED_LEAD_TIME,VARIABLE_LEAD_TIME,WIP_SUPPLY_LOCATOR_ID,WIP_SUPPLY_TYPE,WIP_SUPPLY_SUBINVENTORY,PRIMARY_UOM_CODE,PRIMARY_UNIT_OF_MEASURE,ALLOWED_UNITS_LOOKUP_CODE,COST_OF_SALES_ACCOUNT,SALES_ACCOUNT,DEFAULT_INCLUDE_IN_ROLLUP_FLAG,INVENTORY_ITEM_STATUS_CODE,INVENTORY_PLANNING_CODE,PLANNER_CODE,PLANNING_MAKE_BUY_CODE,FIXED_LOT_MULTIPLIER,ROUNDING_CONTROL_TYPE,CARRYING_COST,POSTPROCESSING_LEAD_TIME,PREPROCESSING_LEAD_TIME,FULL_LEAD_TIME,ORDER_COST,MRP_SAFETY_STOCK_PERCENT,MRP_SAFETY_STOCK_CODE,MIN_MINMAX_QUANTITY,MAX_MINMAX_QUANTITY,MINIMUM_ORDER_QUANTITY,FIXED_ORDER_QUANTITY,FIXED_DAYS_SUPPLY,MAXIMUM_ORDER_QUANTITY,ATP_RULE_ID,PICKING_RULE_ID,RESERVABLE_TYPE,POSITIVE_MEASUREMENT_ERROR,NEGATIVE_MEASUREMENT_ERROR,ENGINEERING_ECN_CODE,ENGINEERING_ITEM_ID,ENGINEERING_DATE,SERVICE_STARTING_DELAY,VENDOR_WARRANTY_FLAG,SERVICEABLE_COMPONENT_FLAG,SERVICEABLE_PRODUCT_FLAG,BASE_WARRANTY_SERVICE_ID,PAYMENT_TERMS_ID,PREVENTIVE_MAINTENANCE_FLAG,PRIMARY_SPECIALIST_ID,SECONDARY_SPECIALIST_ID,SERVICEABLE_ITEM_CLASS_ID,TIME_BILLABLE_FLAG,MATERIAL_BILLABLE_FLAG,EXPENSE_BILLABLE_FLAG,PRORATE_SERVICE_FLAG,COVERAGE_SCHEDULE_ID,SERVICE_DURATION_PERIOD_CODE,SERVICE_DURATION,WARRANTY_VENDOR_ID,MAX_WARRANTY_AMOUNT,RESPONSE_TIME_PERIOD_CODE,RESPONSE_TIME_VALUE,NEW_REVISION_CODE,INVOICEABLE_ITEM_FLAG,TAX_CODE,INVOICE_ENABLED_FLAG,MUST_USE_APPROVED_VENDOR_FLAG,REQUEST_ID,PROGRAM_APPLICATION_ID,PROGRAM_ID,PROGRAM_UPDATE_DATE,OUTSIDE_OPERATION_FLAG,OUTSIDE_OPERATION_UOM_TYPE,SAFETY_STOCK_BUCKET_DAYS,AUTO_REDUCE_MPS,COSTING_ENABLED_FLAG,AUTO_CREATED_CONFIG_FLAG,CYCLE_COUNT_ENABLED_FLAG,ITEM_TYPE,MODEL_CONFIG_CLAUSE_NAME,SHIP_MODEL_COMPLETE_FLAG,MRP_PLANNING_CODE,RETURN_INSPECTION_REQUIREMENT,ATO_FORECAST_CONTROL,RELEASE_TIME_FENCE_CODE,RELEASE_TIME_FENCE_DAYS,CONTAINER_ITEM_FLAG,VEHICLE_ITEM_FLAG,MAXIMUM_LOAD_WEIGHT,MINIMUM_FILL_PERCENT,CONTAINER_TYPE_CODE,INTERNAL_VOLUME,WH_UPDATE_DATE,PRODUCT_FAMILY_ITEM_ID,GLOBAL_ATTRIBUTE_CATEGORY,GLOBAL_ATTRIBUTE1,GLOBAL_ATTRIBUTE2,GLOBAL_ATTRIBUTE3,GLOBAL_ATTRIBUTE4,GLOBAL_ATTRIBUTE5,GLOBAL_ATTRIBUTE6,GLOBAL_ATTRIBUTE7,GLOBAL_ATTRIBUTE8,GLOBAL_ATTRIBUTE9,GLOBAL_ATTRIBUTE10,PURCHASING_TAX_CODE,OVERCOMPLETION_TOLERANCE_TYPE,OVERCOMPLETION_TOLERANCE_VALUE,EFFECTIVITY_CONTROL,CHECK_SHORTAGES_FLAG,OVER_SHIPMENT_TOLERANCE,UNDER_SHIPMENT_TOLERANCE,OVER_RETURN_TOLERANCE,UNDER_RETURN_TOLERANCE,EQUIPMENT_TYPE,RECOVERED_PART_DISP_CODE,DEFECT_TRACKING_ON_FLAG,USAGE_ITEM_FLAG,EVENT_FLAG,ELECTRONIC_FLAG,DOWNLOADABLE_FLAG,VOL_DISCOUNT_EXEMPT_FLAG,COUPON_EXEMPT_FLAG,COMMS_NL_TRACKABLE_FLAG,ASSET_CREATION_CODE,COMMS_ACTIVATION_REQD_FLAG,ORDERABLE_ON_WEB_FLAG,BACK_ORDERABLE_FLAG,WEB_STATUS,INDIVISIBLE_FLAG,DIMENSION_UOM_CODE,UNIT_LENGTH,UNIT_WIDTH,UNIT_HEIGHT,BULK_PICKED_FLAG,LOT_STATUS_ENABLED,DEFAULT_LOT_STATUS_ID,SERIAL_STATUS_ENABLED,DEFAULT_SERIAL_STATUS_ID,LOT_SPLIT_ENABLED,LOT_MERGE_ENABLED,INVENTORY_CARRY_PENALTY,OPERATION_SLACK_PENALTY,FINANCING_ALLOWED_FLAG,EAM_ITEM_TYPE,EAM_ACTIVITY_TYPE_CODE,EAM_ACTIVITY_CAUSE_CODE,EAM_ACT_NOTIFICATION_FLAG,EAM_ACT_SHUTDOWN_STATUS,DUAL_UOM_CONTROL,SECONDARY_UOM_CODE,DUAL_UOM_DEVIATION_HIGH,DUAL_UOM_DEVIATION_LOW,CONTRACT_ITEM_TYPE_CODE,SUBSCRIPTION_DEPEND_FLAG,SERV_REQ_ENABLED_CODE,SERV_BILLING_ENABLED_FLAG,SERV_IMPORTANCE_LEVEL,PLANNED_INV_POINT_FLAG,LOT_TRANSLATE_ENABLED,DEFAULT_SO_SOURCE_TYPE,CREATE_SUPPLY_FLAG,SUBSTITUTION_WINDOW_CODE,SUBSTITUTION_WINDOW_DAYS,IB_ITEM_INSTANCE_CLASS,CONFIG_MODEL_TYPE,LOT_SUBSTITUTION_ENABLED,MINIMUM_LICENSE_QUANTITY,EAM_ACTIVITY_SOURCE_CODE,LIFECYCLE_ID,CURRENT_PHASE_ID,OBJECT_VERSION_NUMBER,CDB_DATA_SOURCE,CDB_ENQUEUE_TIME,CDB_DEQUEUE_TIME,CDB_ENQUEUE_SEQ from MTL_SYSTEM_ITEMS_B where \\\$CONDITIONS \" --target-dir /app/dev/SmartAnalytics/sqoop_temp//MTL_SYSTEM_ITEMS_B -m 4 --split-by INVENTORY_ITEM_ID --hive-import --hive-overwrite --hive-table installbase.MTL_SYSTEM_ITEMS_B --null-string '\\\\N' --null-non-string '\\\\N' --hive-delims-replacement '<EOL>' --map-column-hive INVENTORY_ITEM_ID=BIGINT,ORGANIZATION_ID=BIGINT,LAST_UPDATE_DATE=TIMESTAMP,LAST_UPDATED_BY=BIGINT,CREATION_DATE=TIMESTAMP,CREATED_BY=BIGINT,LAST_UPDATE_LOGIN=BIGINT,SUMMARY_FLAG=STRING,ENABLED_FLAG=STRING,START_DATE_ACTIVE=TIMESTAMP,END_DATE_ACTIVE=TIMESTAMP,DESCRIPTION=STRING,BUYER_ID=BIGINT,ACCOUNTING_RULE_ID=BIGINT,INVOICING_RULE_ID=BIGINT,SEGMENT1=STRING,SEGMENT2=STRING,SEGMENT3=STRING,SEGMENT4=STRING,SEGMENT5=STRING,SEGMENT6=STRING,SEGMENT7=STRING,SEGMENT8=STRING,SEGMENT9=STRING,SEGMENT10=STRING,SEGMENT11=STRING,SEGMENT12=STRING,SEGMENT13=STRING,SEGMENT14=STRING,SEGMENT15=STRING,SEGMENT16=STRING,SEGMENT17=STRING,SEGMENT18=STRING,SEGMENT19=STRING,SEGMENT20=STRING,ATTRIBUTE_CATEGORY=STRING,ATTRIBUTE1=STRING,ATTRIBUTE2=STRING,ATTRIBUTE3=STRING,ATTRIBUTE4=STRING,ATTRIBUTE5=STRING,ATTRIBUTE6=STRING,ATTRIBUTE7=STRING,ATTRIBUTE8=STRING,ATTRIBUTE9=STRING,ATTRIBUTE10=STRING,ATTRIBUTE11=STRING,ATTRIBUTE12=STRING,ATTRIBUTE13=STRING,ATTRIBUTE14=STRING,ATTRIBUTE15=STRING,PURCHASING_ITEM_FLAG=STRING,SHIPPABLE_ITEM_FLAG=STRING,CUSTOMER_ORDER_FLAG=STRING,INTERNAL_ORDER_FLAG=STRING,SERVICE_ITEM_FLAG=STRING,INVENTORY_ITEM_FLAG=STRING,ENG_ITEM_FLAG=STRING,INVENTORY_ASSET_FLAG=STRING,PURCHASING_ENABLED_FLAG=STRING,CUSTOMER_ORDER_ENABLED_FLAG=STRING,INTERNAL_ORDER_ENABLED_FLAG=STRING,SO_TRANSACTIONS_FLAG=STRING,MTL_TRANSACTIONS_ENABLED_FLAG=STRING,STOCK_ENABLED_FLAG=STRING,BOM_ENABLED_FLAG=STRING,BUILD_IN_WIP_FLAG=STRING,REVISION_QTY_CONTROL_CODE=BIGINT,ITEM_CATALOG_GROUP_ID=BIGINT,CATALOG_STATUS_FLAG=STRING,RETURNABLE_FLAG=STRING,DEFAULT_SHIPPING_ORG=BIGINT,COLLATERAL_FLAG=STRING,TAXABLE_FLAG=STRING,QTY_RCV_EXCEPTION_CODE=STRING,ALLOW_ITEM_DESC_UPDATE_FLAG=STRING,INSPECTION_REQUIRED_FLAG=STRING,RECEIPT_REQUIRED_FLAG=STRING,MARKET_PRICE=BIGINT,HAZARD_CLASS_ID=BIGINT,RFQ_REQUIRED_FLAG=STRING,QTY_RCV_TOLERANCE=BIGINT,LIST_PRICE_PER_UNIT=BIGINT,UN_NUMBER_ID=BIGINT,PRICE_TOLERANCE_PERCENT=BIGINT,ASSET_CATEGORY_ID=BIGINT,ROUNDING_FACTOR=BIGINT,UNIT_OF_ISSUE=STRING,ENFORCE_SHIP_TO_LOCATION_CODE=STRING,ALLOW_SUBSTITUTE_RECEIPTS_FLAG=STRING,ALLOW_UNORDERED_RECEIPTS_FLAG=STRING,ALLOW_EXPRESS_DELIVERY_FLAG=STRING,DAYS_EARLY_RECEIPT_ALLOWED=BIGINT,DAYS_LATE_RECEIPT_ALLOWED=BIGINT,RECEIPT_DAYS_EXCEPTION_CODE=STRING,RECEIVING_ROUTING_ID=BIGINT,INVOICE_CLOSE_TOLERANCE=BIGINT,RECEIVE_CLOSE_TOLERANCE=BIGINT,AUTO_LOT_ALPHA_PREFIX=STRING,START_AUTO_LOT_NUMBER=STRING,LOT_CONTROL_CODE=BIGINT,SHELF_LIFE_CODE=BIGINT,SHELF_LIFE_DAYS=BIGINT,SERIAL_NUMBER_CONTROL_CODE=BIGINT,START_AUTO_SERIAL_NUMBER=STRING,AUTO_SERIAL_ALPHA_PREFIX=STRING,SOURCE_TYPE=BIGINT,SOURCE_ORGANIZATION_ID=BIGINT,SOURCE_SUBINVENTORY=STRING,EXPENSE_ACCOUNT=BIGINT,ENCUMBRANCE_ACCOUNT=BIGINT,RESTRICT_SUBINVENTORIES_CODE=BIGINT,UNIT_WEIGHT=BIGINT,WEIGHT_UOM_CODE=STRING,VOLUME_UOM_CODE=STRING,UNIT_VOLUME=BIGINT,RESTRICT_LOCATORS_CODE=BIGINT,LOCATION_CONTROL_CODE=BIGINT,SHRINKAGE_RATE=BIGINT,ACCEPTABLE_EARLY_DAYS=BIGINT,PLANNING_TIME_FENCE_CODE=BIGINT,DEMAND_TIME_FENCE_CODE=BIGINT,LEAD_TIME_LOT_SIZE=BIGINT,STD_LOT_SIZE=BIGINT,CUM_MANUFACTURING_LEAD_TIME=BIGINT,OVERRUN_PERCENTAGE=BIGINT,MRP_CALCULATE_ATP_FLAG=STRING,ACCEPTABLE_RATE_INCREASE=BIGINT,ACCEPTABLE_RATE_DECREASE=BIGINT,CUMULATIVE_TOTAL_LEAD_TIME=BIGINT,PLANNING_TIME_FENCE_DAYS=BIGINT,DEMAND_TIME_FENCE_DAYS=BIGINT,END_ASSEMBLY_PEGGING_FLAG=STRING,REPETITIVE_PLANNING_FLAG=STRING,PLANNING_EXCEPTION_SET=STRING,BOM_ITEM_TYPE=BIGINT,PICK_COMPONENTS_FLAG=STRING,REPLENISH_TO_ORDER_FLAG=STRING,BASE_ITEM_ID=BIGINT,ATP_COMPONENTS_FLAG=STRING,ATP_FLAG=STRING,FIXED_LEAD_TIME=BIGINT,VARIABLE_LEAD_TIME=BIGINT,WIP_SUPPLY_LOCATOR_ID=BIGINT,WIP_SUPPLY_TYPE=BIGINT,WIP_SUPPLY_SUBINVENTORY=STRING,PRIMARY_UOM_CODE=STRING,PRIMARY_UNIT_OF_MEASURE=STRING,ALLOWED_UNITS_LOOKUP_CODE=BIGINT,COST_OF_SALES_ACCOUNT=BIGINT,SALES_ACCOUNT=BIGINT,DEFAULT_INCLUDE_IN_ROLLUP_FLAG=STRING,INVENTORY_ITEM_STATUS_CODE=STRING,INVENTORY_PLANNING_CODE=BIGINT,PLANNER_CODE=STRING,PLANNING_MAKE_BUY_CODE=BIGINT,FIXED_LOT_MULTIPLIER=BIGINT,ROUNDING_CONTROL_TYPE=BIGINT,CARRYING_COST=BIGINT,POSTPROCESSING_LEAD_TIME=BIGINT,PREPROCESSING_LEAD_TIME=BIGINT,FULL_LEAD_TIME=BIGINT,ORDER_COST=BIGINT,MRP_SAFETY_STOCK_PERCENT=BIGINT,MRP_SAFETY_STOCK_CODE=BIGINT,MIN_MINMAX_QUANTITY=BIGINT,MAX_MINMAX_QUANTITY=BIGINT,MINIMUM_ORDER_QUANTITY=BIGINT,FIXED_ORDER_QUANTITY=BIGINT,FIXED_DAYS_SUPPLY=BIGINT,MAXIMUM_ORDER_QUANTITY=BIGINT,ATP_RULE_ID=BIGINT,PICKING_RULE_ID=BIGINT,RESERVABLE_TYPE=BIGINT,POSITIVE_MEASUREMENT_ERROR=BIGINT,NEGATIVE_MEASUREMENT_ERROR=BIGINT,ENGINEERING_ECN_CODE=STRING,ENGINEERING_ITEM_ID=BIGINT,ENGINEERING_DATE=TIMESTAMP,SERVICE_STARTING_DELAY=BIGINT,VENDOR_WARRANTY_FLAG=STRING,SERVICEABLE_COMPONENT_FLAG=STRING,SERVICEABLE_PRODUCT_FLAG=STRING,BASE_WARRANTY_SERVICE_ID=BIGINT,PAYMENT_TERMS_ID=BIGINT,PREVENTIVE_MAINTENANCE_FLAG=STRING,PRIMARY_SPECIALIST_ID=BIGINT,SECONDARY_SPECIALIST_ID=BIGINT,SERVICEABLE_ITEM_CLASS_ID=BIGINT,TIME_BILLABLE_FLAG=STRING,MATERIAL_BILLABLE_FLAG=STRING,EXPENSE_BILLABLE_FLAG=STRING,PRORATE_SERVICE_FLAG=STRING,COVERAGE_SCHEDULE_ID=BIGINT,SERVICE_DURATION_PERIOD_CODE=STRING,SERVICE_DURATION=BIGINT,WARRANTY_VENDOR_ID=BIGINT,MAX_WARRANTY_AMOUNT=BIGINT,RESPONSE_TIME_PERIOD_CODE=STRING,RESPONSE_TIME_VALUE=BIGINT,NEW_REVISION_CODE=STRING,INVOICEABLE_ITEM_FLAG=STRING,TAX_CODE=STRING,INVOICE_ENABLED_FLAG=STRING,MUST_USE_APPROVED_VENDOR_FLAG=STRING,REQUEST_ID=BIGINT,PROGRAM_APPLICATION_ID=BIGINT,PROGRAM_ID=BIGINT,PROGRAM_UPDATE_DATE=TIMESTAMP,OUTSIDE_OPERATION_FLAG=STRING,OUTSIDE_OPERATION_UOM_TYPE=STRING,SAFETY_STOCK_BUCKET_DAYS=BIGINT,AUTO_REDUCE_MPS=BIGINT,COSTING_ENABLED_FLAG=STRING,AUTO_CREATED_CONFIG_FLAG=STRING,CYCLE_COUNT_ENABLED_FLAG=STRING,ITEM_TYPE=STRING,MODEL_CONFIG_CLAUSE_NAME=STRING,SHIP_MODEL_COMPLETE_FLAG=STRING,MRP_PLANNING_CODE=BIGINT,RETURN_INSPECTION_REQUIREMENT=BIGINT,ATO_FORECAST_CONTROL=BIGINT,RELEASE_TIME_FENCE_CODE=BIGINT,RELEASE_TIME_FENCE_DAYS=BIGINT,CONTAINER_ITEM_FLAG=STRING,VEHICLE_ITEM_FLAG=STRING,MAXIMUM_LOAD_WEIGHT=BIGINT,MINIMUM_FILL_PERCENT=BIGINT,CONTAINER_TYPE_CODE=STRING,INTERNAL_VOLUME=BIGINT,WH_UPDATE_DATE=TIMESTAMP,PRODUCT_FAMILY_ITEM_ID=BIGINT,GLOBAL_ATTRIBUTE_CATEGORY=STRING,GLOBAL_ATTRIBUTE1=STRING,GLOBAL_ATTRIBUTE2=STRING,GLOBAL_ATTRIBUTE3=STRING,GLOBAL_ATTRIBUTE4=STRING,GLOBAL_ATTRIBUTE5=STRING,GLOBAL_ATTRIBUTE6=STRING,GLOBAL_ATTRIBUTE7=STRING,GLOBAL_ATTRIBUTE8=STRING,GLOBAL_ATTRIBUTE9=STRING,GLOBAL_ATTRIBUTE10=STRING,PURCHASING_TAX_CODE=STRING,OVERCOMPLETION_TOLERANCE_TYPE=BIGINT,OVERCOMPLETION_TOLERANCE_VALUE=BIGINT,EFFECTIVITY_CONTROL=BIGINT,CHECK_SHORTAGES_FLAG=STRING,OVER_SHIPMENT_TOLERANCE=BIGINT,UNDER_SHIPMENT_TOLERANCE=BIGINT,OVER_RETURN_TOLERANCE=BIGINT,UNDER_RETURN_TOLERANCE=BIGINT,EQUIPMENT_TYPE=BIGINT,RECOVERED_PART_DISP_CODE=STRING,DEFECT_TRACKING_ON_FLAG=STRING,USAGE_ITEM_FLAG=STRING,EVENT_FLAG=STRING,ELECTRONIC_FLAG=STRING,DOWNLOADABLE_FLAG=STRING,VOL_DISCOUNT_EXEMPT_FLAG=STRING,COUPON_EXEMPT_FLAG=STRING,COMMS_NL_TRACKABLE_FLAG=STRING,ASSET_CREATION_CODE=STRING,COMMS_ACTIVATION_REQD_FLAG=STRING,ORDERABLE_ON_WEB_FLAG=STRING,BACK_ORDERABLE_FLAG=STRING,WEB_STATUS=STRING,INDIVISIBLE_FLAG=STRING,DIMENSION_UOM_CODE=STRING,UNIT_LENGTH=BIGINT,UNIT_WIDTH=BIGINT,UNIT_HEIGHT=BIGINT,BULK_PICKED_FLAG=STRING,LOT_STATUS_ENABLED=STRING,DEFAULT_LOT_STATUS_ID=BIGINT,SERIAL_STATUS_ENABLED=STRING,DEFAULT_SERIAL_STATUS_ID=BIGINT,LOT_SPLIT_ENABLED=STRING,LOT_MERGE_ENABLED=STRING,INVENTORY_CARRY_PENALTY=BIGINT,OPERATION_SLACK_PENALTY=BIGINT,FINANCING_ALLOWED_FLAG=STRING,EAM_ITEM_TYPE=BIGINT,EAM_ACTIVITY_TYPE_CODE=STRING,EAM_ACTIVITY_CAUSE_CODE=STRING,EAM_ACT_NOTIFICATION_FLAG=STRING,EAM_ACT_SHUTDOWN_STATUS=STRING,DUAL_UOM_CONTROL=BIGINT,SECONDARY_UOM_CODE=STRING,DUAL_UOM_DEVIATION_HIGH=BIGINT,DUAL_UOM_DEVIATION_LOW=BIGINT,CONTRACT_ITEM_TYPE_CODE=STRING,SUBSCRIPTION_DEPEND_FLAG=STRING,SERV_REQ_ENABLED_CODE=STRING,SERV_BILLING_ENABLED_FLAG=STRING,SERV_IMPORTANCE_LEVEL=BIGINT,PLANNED_INV_POINT_FLAG=STRING,LOT_TRANSLATE_ENABLED=STRING,DEFAULT_SO_SOURCE_TYPE=STRING,CREATE_SUPPLY_FLAG=STRING,SUBSTITUTION_WINDOW_CODE=BIGINT,SUBSTITUTION_WINDOW_DAYS=BIGINT,IB_ITEM_INSTANCE_CLASS=STRING,CONFIG_MODEL_TYPE=STRING,LOT_SUBSTITUTION_ENABLED=STRING,MINIMUM_LICENSE_QUANTITY=BIGINT,EAM_ACTIVITY_SOURCE_CODE=STRING,LIFECYCLE_ID=BIGINT,CURRENT_PHASE_ID=BIGINT,OBJECT_VERSION_NUMBER=BIGINT,CDB_DATA_SOURCE=STRING,CDB_ENQUEUE_TIME=TIMESTAMP,CDB_DEQUEUE_TIME=TIMESTAMP,CDB_ENQUEUE_SEQ=BIGINT --boundary-query 'select (select min(INVENTORY_ITEM_ID) from MTL_SYSTEM_ITEMS_B) as minid ,(select max(INVENTORY_ITEM_ID) from MTL_SYSTEM_ITEMS_B) as maxid from dual' " >> /apps/pentaho_nfs/installbase/input/poc/logs/IB_logs.log 2>&1" public void run() { ProcessBuilder processbuilder = new ProcessBuilder(command); LOGGER.info(command); try { Process process = processbuilder.inheritIO().start(); System.out.println("inside process builder "); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String readline; while ((readline = reader.readLine()) != null) { LOGGER.info(readline); } } catch (Exception e) { LOGGER.error(e.getMessage()); } } ,并且每次都将随机数生成器初始化为相同的内容(除非您在计算过程中碰巧越过第二个边界,这不太可能它应该很快),所以结果应该是一样的。