Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+5 votes

In our program, we have several different areas where you can type CW using either paddles or a straight key. We have a separate class that handles input, and there is a handle typing method that is being ran in a thread. It handles the keyboard input and then sends the CW back to the controller to then be displayed on screen. A thread starts when you select an input mode, and then stops when you change the mode of input or leave that practice mode.

This works in all of the practice modes upon starting the program. You can go into any of them and it will work. You should then be able to switch between modes and it should still work, since the old thread will close and a new one will start. This does not always work however.

There is no clear cause for it, as for it will stop working at random times. Sometimes you will be able to switch between modes 5-6 times before it stops working, other it will stop after switching 1 time. There is no certain practice mode causing it either, as it can happen when switching from any mode to any other mode, including back to the same mode.

I was wondering if it could be something with the thread or something else could cause it. Please let me know if you have any idea of where to look for a cause or what to try since I am not getting any errors either.

asked ago in CSC 305 Fall 2024 by (354 points)

1 Answer

0 votes

This is not a solution but perhaps a debugging idea - have you tried adding in print statements or testing somehow to see if the thread is closing every time? I wonder if they overlap or something if the threads don’t close properly.

answered ago by (2.8k points)
+1

I added a print statement to right after where the thread starts as well as into the method that handles stopping the thread. I also added one to make sure I am outputting to the right controller. Everything seems to be working fine but I am still having this issue. Is there a way I could look deeper into the thread to see if it is something in there or any ideas about what else could be causing it?

0

If you go into debug mode, you can click through each step individually and maybe you'd be able to catch it then... not sure otherwise.

...