Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread.sleep

 
Rishi Chopra
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class 'BaseClass' that extends a java.lang.Thread but does not implement run() method. but it defines some common methods

SubClass
Now i have a subclass 'SubClass' that extends 'BaseClass' and provides a run() method implementation. In the main method in this class, start method is called is on object of the baseclass. In the run method, some process is done and then thread is made to sleep for 10 seconds. After wakeup,it should redo the process (calling a stored proc )

SubClass2
There is another subclass 'SubClass2' that extends 'BaseClass' and provides a run() method implementation. In the main method in this class, start method is called is on object of the baseclass. In the run method, some process is done and then thread is made to sleep for 10 seconds. After wakeup,it should redo the process (calling a stored proc )

Now these two subclasses are run as a unix process , but the problem is these processes dies off automatically..


HOW ???
 
Santhosh Kumar
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you post the code snippets, makes it easier to clearly answer you question.

I believe (from your post) that you are creating objects like new BaseClass(), in SubClass.main and SubClass2.main methods. In this case, Thread object would execute its own run() method (which is empty implementation) as it cannot see the SubClass.run and SubClass2.run methods. That's the reason the threads are dieing immediately.

Changin new BaseClass(), to new SubClass() or new SubClass2() would fix the problem and Thread object would be able to run the respective run methods.
 
Rishi Chopra
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am creating new SubClass() and new SubClass2() in the main only and not new BaseClass(), then also after sometime the processes dies off i.e it does not come out of sleep mode
 
Henry Wong
author
Marshal
Pie
Posts: 20889
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we have some code that shows what you are describing? the phrase "sometime the processes dies off i.e it does not come out of sleep mode" doesn't describe it very well.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic