Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
jTDS JDBC Driver Source Code Files
jTDS JDBC Driver Source Code Files are provided in the
source package file, jtds-1.3.1-fyi.zip.
You can browse jTDS JDBC Driver Source Code files below:
✍: FYIcenter.com
⏎ net/sourceforge/jtds/jdbc/Semaphore.java
//jTDS JDBC Driver for Microsoft SQL Server and Sybase
//Copyright (C) 2004 The jTDS Project
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
package net.sourceforge.jtds.jdbc;
/**
* Simple semaphore class used to serialize access requests over the network
* connection.
* <p/>
* Based on the code originally written by Doug Lea. Once JDK 1.5 is the
* standard this class can be replaced by the
* <code>java.util.concurrent.Sempahore</code> class.
*
* @author Mike Hutchinson
* @version $Id: Semaphore.java,v 1.1 2004-12-20 15:51:17 alin_sinpalean Exp $
*/
public class Semaphore {
/**
* Current number of available permits.
*/
protected long permits;
/**
* Create a Semaphore with the given initial number of permits. Using a
* seed of one makes the semaphore act as a mutual exclusion lock. Negative
* seeds are also allowed, in which case no acquires will proceed until the
* number of releases has pushed the number of permits past 0.
*/
public Semaphore(long initialPermits) {
permits = initialPermits;
}
/**
* Wait until a permit is available, and take one.
*/
public void acquire() throws InterruptedException {
if (Thread.interrupted()) {
throw new InterruptedException();
}
synchronized (this) {
try {
while (permits <= 0) {
wait();
}
--permits;
} catch (InterruptedException ex) {
notify();
throw ex;
}
}
}
/**
* Wait at most msecs millisconds for a permit.
*/
public boolean attempt(long msecs) throws InterruptedException {
if (Thread.interrupted()) {
throw new InterruptedException();
}
synchronized (this) {
if (permits > 0) {
--permits;
return true;
} else if (msecs <= 0) {
return false;
} else {
try {
long startTime = System.currentTimeMillis();
long waitTime = msecs;
while (true) {
wait(waitTime);
if (permits > 0) {
--permits;
return true;
} else {
waitTime = msecs - (System.currentTimeMillis() - startTime);
if (waitTime <= 0) {
return false;
}
}
}
} catch (InterruptedException ex) {
notify();
throw ex;
}
}
}
}
/**
* Release a permit.
*/
public synchronized void release() {
++permits;
notify();
}
/**
* Release N permits. <code>release(n)</code> is equivalent in effect to:
* <pre>
* for (int i = 0; i < n; ++i) release();
* </pre>
* <p/>
* But may be more efficient in some semaphore implementations.
*
* @exception IllegalArgumentException if n is negative
*/
public synchronized void release(long n) {
if (n < 0) {
throw new IllegalArgumentException("Negative argument");
}
permits += n;
for (long i = 0; i < n; ++i) {
notify();
}
}
/**
* Return the current number of available permits. Returns an accurate, but
* possibly unstable value, that may change immediately after returning.
*/
public synchronized long permits() {
return permits;
}
}
⏎ net/sourceforge/jtds/jdbc/Semaphore.java
Or download all of them as a single archive file:
File name: jtds-1.3.1-fyi.zip File size: 323160 bytes Release date: 2013-06-08 Download
⇐ What Is jtds-1.3.1-dist.zip?
2016-11-26, ≈17🔥, 0💬
Popular Posts:
maven-compat-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Compact module. The JAR file name may ...
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
How to download and install ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is a Java 5 J...
What Is XMLBeans xbean.jar 2.6.0? XMLBeans xbean.jar 2.6.0 is the JAR file for Apache XMLBeans 2.6.0...
What is the jaxp\TypeInfoWriter.java provided in the Apache Xerces package? I have Apache Xerces 2.1...