Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id E60031337B93 for ; Tue, 29 Mar 2011 05:36:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 29386-07 for ; Tue, 29 Mar 2011 08:36:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id DCA5F1337B49 for ; Tue, 29 Mar 2011 05:36:21 -0300 (ADT) Received: by fxm17 with SMTP id 17so5039fxm.19 for ; Tue, 29 Mar 2011 01:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=0fjgcb4VNiQOh2Ed5jGMJmWfg86GEu3Dh/okaWaFMys=; b=fDPzJLfDnqNzblvQ3Tfk+3uWGs0SvhR5N7XSG7f5A3lIQv+fEw43KVrHBoCFl36gln joWSwyhVj3LxWRvuV0Xjm4S150u7f1+GJSJMs4VBL1ZUqKkG/i6eYRa9LptMtpllUCw/ HqXs2KEo6/kLXQ18fburWjQFxN/GK7yZsv5Rk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=dqBUa7k0vSGiXRYAN58S4NxmjFEhDUqFaXfdCWA6Cppc0d5NKw17eb9Kjqz+9oYFi7 KdpfxAfdOnDmZPzwChDkezNQcmCySCYdPdX66hghN9/eTzJdE2Zt/xBt5KD8VCHTdAif P+512mG3Ocd0YkpCGbsECSR2r/rjDJpTYry6E= Received: by 10.223.78.138 with SMTP id l10mr4012896fak.106.1301387780311; Tue, 29 Mar 2011 01:36:20 -0700 (PDT) Received: from [10.1.1.57] (skuns.zoral.com.ua [91.193.166.194]) by mx.google.com with ESMTPS id j11sm1832104faa.44.2011.03.29.01.36.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Mar 2011 01:36:18 -0700 (PDT) Message-ID: <4D919A02.60607@gmail.com> Date: Tue, 29 Mar 2011 11:36:18 +0300 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: Craig Ringer CC: Dave Cramer , List Subject: Re: JDBC gripe list References: <4D914191.8050103@postnewspapers.com.au> In-Reply-To: <4D914191.8050103@postnewspapers.com.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.346 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201103/103 X-Sequence-Number: 21658 29.03.11 05:18, Craig Ringer написав(ла): > On 03/27/2011 11:14 PM, Dave Cramer wrote: >> Adding to the list is statement timeout. I seem to recall the issue is >> we do not want to spawn a thread for each statement which seems to be >> the only way to do this. Alternatively we could use timers, but I >> presume they just spawn threads as well. > > Timers can use one shared thread for all timers, either a generic > timer thread provided by the JVM or (IMO better in this case) one > dedicated to that timer pool. I think it'd be an ideal way to do it > personally - the JDBC driver has several issues that'd be solvable by > adding a single thread to use for various timers, etc. > > If there are concerns about the driver spawning a thread, it wouldn't > be too tricky to make timer-requiring features conditional on a > connection param, so if no connections that were going to use > timer-based features were made, no thread would be spawned. Personally > I don't think a single shared thread is worth worrying about, though. > Have you *seen* the thread lists in a modern Java app? Threads are > extremely low cost when idle, and are already heavily used throughout > Java and the JVM. Please note that you will get into problems with classloaders and different containers. E.g. running a thread from classloader will prevent this classloader to be GCd. Tomcat handles this (with a lot of warnings), but it is not recommended practice. See http://www.theserverside.com/discussions/thread.tss?thread_id=44353 or http://stackoverflow.com/questions/533783/why-spawning-threads-in-j2ee-container-is-discouraged Best regards, Vitalii Tymchyshyn