Home arrow static arrow Java Programming [Archive] - threads and method execution...
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - threads and method execution...
This topic has 4 replies on 1 page.

Posts:51
Registered: 10/11/99
threads and method execution...  
Aug 7, 2004 2:42 PM



 
Hi,
I am coding a remote access SQL database, and have hit a brick wall with my connection threads trying to run methods contained in other classes.

The main class is [serverControl] which contains [connectionManager] that itself contains x number of [socketAgent]'s (these are threaded).
I can connect to these socketagents and run methods contained with in them, but when the socketagents try to run methods held in other classes nothing happens upon execution :

response =  new messageObject("request_response", serControl.getProManager().getProjectList());


the above batch of get methods would return a null due to lack of execution and as a result send an invalid [messageObject].

I know the methods do work since I can call them from non-threaded classes and get a response.
Any ideas why the methods are not being executed correctly; and how to fix it?

thanks for any help,
seb.

 

Posts:37,103
Registered: 3/30/99
Re: threads and method execution...  
Aug 7, 2004 6:06 PM (reply 1 of 4)



 
Umm.... you haven't really explained your problem very well. Other classes can run socketagents methods, but socketagents can't run other classes' methods? Is that what you're saying? I'll be really impressed if somebody can take that information and tell you what's wrong.
 

Posts:826
Registered: 7/1/03
Re: threads and method execution...  
Aug 7, 2004 6:15 PM (reply 2 of 4)



 
I'll give it a bat.

The main class is [serverControl] which contains
[connectionManager] that itself contains x number of
[socketAgent]'s (these are threaded).

Why? You are ignoring the connection pooling available on the platform already. This avoids the need to write multithreaded code and have to solve the data-race/deadlock issues that are an inherent liability of threaded code.

I can connect to these socketagents and run methods
contained with in them, but when the socketagents try
to run methods held in other classes nothing happens
upon execution :

...sounds like the above mentioned deadlock danger manifested itself...

Any ideas why the methods are not being executed
correctly; and how to fix it?

My approach would be to use javax.sql.DataSource in this instance, i.e. use the platform supplied connection pooling and remove your broken connection pool from the picture completely.

Take it or leave it :-)

hth,

/k1
 

Posts:51
Registered: 10/11/99
Re: threads and method execution...  
Aug 8, 2004 3:36 AM (reply 3 of 4)



 
komone, thanks for pointing out that class; it would be useful but the socketagents have to access several different classes each returning different data types: ResultSets, GUI's and JARs. so I'm forced to keep this problamatic architecture.

thanks anyway.
 

Posts:826
Registered: 7/1/03
Re: threads and method execution...  
Aug 8, 2004 4:23 AM (reply 4 of 4)



 
Now be fair, you did only mention "database" in your OP...

...now you change the goalposts...

...maybe that's how this problematic pool ended up being responsible for database access, GUI component loading and accessing arbitrary jars in the first place... :-P

Good luck with it.

/k1
 
This topic has 4 replies on 1 page.