Problem accessing Properties value in Timer thread

Posted on 2010-01-11
Medium Priority
Last Modified: 2013-12-17
I'm have issue accessing properties values if I use schedular.. In the below code:
in my init() method I set properties value in setConfigProperties() method. If i call processInvoiceFiles() from the init() method, I can retrieve property value in processInvoiceFiles() method. However if I call  startSchedular(); method and then call  processInvoiceFiles(); inside run method I get no values from the properties object. Any help will really be appriciated

public void init(Properties properties){
        * Implements TimerTask's abstract run method.
        public void run(){
          System.out.println("Inside Run method of schedular");
        public void startSchedular(){
              TimerTask runSchedular  = new ASNSchedular();
              Timer timer = new Timer();
              timer.schedule(runSchedular,0, MINUTES);
      public void processInvoiceFiles(){
String out_bound_XML=  configProperties.getProperty("OUT_BOUND_XML_FOLDER_TO_BE_PROCESSED");
Question by:AjooAli
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26290151
Please post the complete source code.

LVL 20

Expert Comment

ID: 26290192
Can you post the complete code so that I can try it out on my local machine? Seems like something is missing.

Accepted Solution

malaki12003 earned 2000 total points
ID: 26290231
I think your problem is that you try to access to value property before realty it be set. because process of setting  and getting property is running concurrently. so you must grantee that access to property happen after property initialization. a question? "why you need to call processInvoiceFiles() in thread?" you can call it in init method. but if it is really your want then create a boolean variable that is a flag at first set it to false and  at end of  processInvoiceFiles set it to true. and wheneever you want to access to property must check if it is set to true if not you have to itrate in a loop to it set to true.
above solution may cause  busy waiting problem but it is easy a better solution is that you use wait/ notify mechanism in java.  

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month9 days, 22 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question