My guess would be that the constructor of CLost somehow blocks and does
not return. Without seeing more of your program I cannot tell you the
exact problem. You probably want to create a separate thread for doing
stuff like printing something every 30 minutes.

Class MyThread extends Thread {
  public void run() {
    long last = System.currentTimeMillis();
    while(true) {
      if((last + 30 * 60 * 1000) <= Sysytem.currentTimeMillis()) {
        System.out.println("30 mins passed");
        last = System.currentTimeMillis();
      }
      try {
        Thread.sleep(1000);
      } catch(InterruptedException ie) {
      }
    }
  }
}

 public static void main(String[] args) throws Exception {
   MoteIF mote = new MoteIF((net.tinyos.util.Messenger)null);
   MyThread mt = new MyThread();
   mt.start();
   CLost c = new CLost(mote);
   //**************************************
 }

Cheers,
Urs


Muhammad Azhar schrieb:
> Hi all,
> 
>   I have some problems with implementing my own Java program.  Let me
> just show a sample of my Java program:
> 
> public class CLost implements MessageListener {
>  private MoteIF mote;
>  //..........
>  public CLost(MoteIF mote) {
>    //register mote and other stuff.........
>  }
> 
>  public void messageReceived(int dstAddr, Message msg) {
>    //do something on receiving packets
>  }
> 
>  public static void main(String[] args) throws Exception {
>    MoteIF mote = new MoteIF((net.tinyos.util.Messenger)null);
>    CLost c = new CLost(mote);
>    //**************************************
>  }
> }
> 
>   Basically, what I want to do is, besides printing out the message
> received, I would also like it to print other messages, which is
> independent of the message received - say at every interval of 30mins,
> I'd want to print "30 mins passed".  Thus, this message should not be in
> the messageReceived(..) method.  When I tried creating another method
> and calling it from the main, it doesn't print out that particular
> message although the conditions were met.  Even when I tried to print:
> System.out.println("Hello");
> in the //************************************** area, it doesn't work
> too.  Any idea how I can do so?
>   Thanks in advance.
> 
> Regards,
> Azhar
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to