• Post Reply Bookmark Topic Watch Topic
  • New Topic

How should i use MultiThread in my program?  RSS feed

 
Mohamed Bilal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends, I am Developing a java Desktop Application in Netbeans. That is for performance counter for all like mysql, Sql Server, etc., I got those counter names and values and store it in a hashmap and load counter name in jtree in a class. And, i wanna display a jfreechart for the selected counter in Jtree, i just write coding for that in a seperate class. The Actual problem is, when i click the button Those two threads not working sequentially. First Thread execute first and complete all(Get updates of counter values and store in hashmap) after that only second thread start to draw graph. how can i manage this? Both threads should execute on given interval by user. If any sample code, please post here. i am stucking Here.

Thanks in advance..


Current Execution Status is,

MySql Occur
MySql Occur
MySql Occur
MySql Occur
MySql Occur
MySql Occur
MySql Occur
MySql Occur
com.mysql.jdbc.JDBC4Connection@14651f2
in Get Connection
In Try
com.mysql.jdbc.JDBC4Connection@1e3f171
in Get Connection
In Try
com.mysql.jdbc.JDBC4Connection@14975d2
in Get Connection
In Try
com.mysql.jdbc.JDBC4Connection@394557
in Get Connection
In Try
com.mysql.jdbc.JDBC4Connection@1e10f02
in Get Connection
In Try
Graph Occur
Graph Occur
Graph Occur
205578
205578
205578
Graph Occur
205578
Graph Occur
205578
com.mysql.jdbc.JDBC4Connection@17007c4
in Get Connection
In Try
com.mysql.jdbc.JDBC4Connection@1344a8
in Get Connection
In Try
Graph Occur
209452
Graph Occur
209475
com.mysql.jdbc.JDBC4Connection@1f21412
in Get Connection
In Try
Graph Occur
210774
com.mysql.jdbc.JDBC4Connection@159990e
in Get Connection
In Try
Graph Occur
212073
com.mysql.jdbc.JDBC4Connection@feaf9c
Graph Occur
213372
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch. Post the relevant excerpts from your code that handle the threads.
 
Luan Cestari
Ranch Hand
Posts: 172
C++ Redhat Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try the lock system? Like using a shared object to lock and notify. That might archive what you want.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you absolutely have to have two Threads, don't even start the second until the first is finished?

Why do you think two Threads are needed if they never run simultaneously?

Bill
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!