Re: [Asterisk-java-users] Problems with concurrent java-threads answering incoming calls
Brought to you by:
srt
From: Julien T. <om...@gm...> - 2008-02-14 16:31:06
|
Stefan Reuter wrote: > would you mind to post your code? Hi, I'm sure that thread will interest me as well. Please, post your code so that Stefan can provide some feedback. Actually, I never posted any question on the ML but I am not so sure of me on how Asterisk-Java handles threads. Think it's one instance of AgiScript for each concurrent thread? So each instance variable access (write?) has to be synchronized? My main example would be something like... public class PlopScript extends BaseAgiScript { private Connection db; // constructor public PlopScript() { // initialize database connection object db = DriverManager.getConnection(...); } public void service(AgiRequest request, AgiChannel channel) throws AgiException { // .... // // so now if i want to query my DB, i need to synchronize // each call using my "db" object? i am correct? // // i mean... let's assume I will have concurrent calls // executing that PlopScript instance } } I know you would say, "it's better/easier to declare variables/objects IN the service method". But, just to be sure... If I would like to have instance members... Let's see Johan's examples and then Stefan (or other gurus) answer, think that will help me... Cheers, Julien |