当前位置: 代码迷 >> J2SE >> java怎么读取properties中的设置的int型数据
  详细解决方案

java怎么读取properties中的设置的int型数据

热度:8927   发布时间:2013-02-25 00:00:00.0
java如何读取properties中的设置的int型数据
Java code
package test;import java.io.IOException;import java.io.InputStream;import java.util.concurrent.ArrayBlockingQueue;import java.util.concurrent.ThreadPoolExecutor;import java.util.concurrent.TimeUnit;import java.util.Properties;public class TestThreadPool {    private static int produceTaskSleepTime ;        private static int produceTaskMaxNumber ;            public static void main(String[] args) {        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("Config.properties");             Properties p = new Properties();             try {              p.load(inputStream);             } catch (IOException e1) {              e1.printStackTrace();             }          // 构造一个线程池        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 4, 3,                TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(3),                new ThreadPoolExecutor.DiscardOldestPolicy());        for (int i = 1; i <= p.getProperty(produceTaskMaxNumber); i++) {            try {                String task = "task@ " + i;                System.out.println("创建任务并提交到线程池中:" + task);                threadPool.execute(new ThreadPoolTask(task));                Thread.sleep(p.getProperty.(produceTaskSleepTime));            } catch (Exception e) {                e.printStackTrace();            }        }    }}


------解决方案--------------------------------------------------------
propreties 配置的属性值,不需要分号呀

produceTaskSleepTime = 2;
produceTaskMaxNumber = 10;

后面的分号去掉
  相关解决方案