0

This is a school assignment I have been working on. I've been back and forth with my tutor and he's been helping me with this but there's something I'm obviously missing here. The program in question takes an argument, "-f filename.txt" and in that filename are a list of things like this

FansOn, 2000
FansOff, 4000
Bell, 2000,5

The program does takes those names and creates classes using reflection and then calls the action() method of the generated classes (FansOn, etc.). It creates a thread for each class and then starts the thread, which generates a message like "Fan is on". On two of the events, PowerOut and WindowMalfunction, it throws a custom exception ControllerException which then needs to grab an object called GreenhouseControls and serialize it to a file called dump.out for later examination. The problem I'm having is being able to call my ghcSuspend() method which should suspend all events immediately after the exception call. In fact, at this point my program just generates massive stack overflow issues. I don't know if I should post my entire code here because I obviously don't want someone else taking my course to just get handed the bulk of code so I don't know what I should post to make you guys understand my issue.

So in my main() method, i create a GreenhouseControls object called gc. GreenhouseControls is the name of the main class file. Eventually, I need this gc object in my custom exception, which is defined and caught in my events.class file

Shaun
  • 2,446
  • 19
  • 33
Richard Chase
  • 407
  • 5
  • 21
  • I wish I knew how to explain it better without posting the entire code. Actually if you google GreenhouseControls.java, youll find some variations of the problem on the internet. One of them was actually the same as my assignment before this one (basically the same problem but without threads and reflection). – Richard Chase Dec 08 '11 at 06:09

1 Answers1

0

I figured this one out. Because my object was being created in the run method, i basically had to pass it through each method that was invokved one after the other until it reached my final method where I needed to deal with it. I was missing some basic OO concepts that ended up creating an infinite loop, overflowing my stack. So we're all good now.

Richard Chase
  • 407
  • 5
  • 21