Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Correct Thread organization.  RSS feed

kuls ab
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some problems in my program, I'd say it is simliar to the producer consumer idea. It involved 4 classes but I will just paste the parts relevant to the threads and explain. Basically I am making a program that performs a line graph every second. One class parses a file for the data to be graphed and when it collects for one second, the other class stores it in a Hash table and allows the class to get() it. And then it continues..
Class Matrix handles starting the threads..

This is the class that goes through a file and gets the data to be graphed,, in this case port numbers. It also checks to see what the next second is and whether we reached that or not. This can be compared to the producer class in java examples. I have done a lot of editing to make it easier to read, if someone would like the full code I can paste that here too.

This class can be compared to Cubbyhole in the java examples. It adds the number of ports to the hash when each second passes and its supposed to allow the get command to happen which is used by the class that graphs (coming next called example2A)

This class was an applet but I converted it.. for graphing. so it implements runnable.

thanks for any help. I know so far it freezes in class Packet when I have just reached a second and I am adding data to the hash table.. it gets to my print statement of we are at wait then it does not continue.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!