⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 synchronizedvariable.html

📁 dfdfddfskfjdsklfjksdljflksjfsjlkfdjlksfjkdsjfsdjkflsjkf
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_03) on Mon May 31 21:03:11 EDT 2004 -->
<TITLE>
SynchronizedVariable (DbUnit 2.1 API)
</TITLE>

<META NAME="keywords" CONTENT="org.dbunit.util.concurrent.SynchronizedVariable class">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    parent.document.title="SynchronizedVariable (DbUnit 2.1 API)";
}
</SCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">

<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/SynchronizedVariable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/dbunit/util/concurrent/SynchronizedInt.html" title="class in org.dbunit.util.concurrent"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/dbunit/util/concurrent/SynchronousChannel.html" title="class in org.dbunit.util.concurrent"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="SynchronizedVariable.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.dbunit.util.concurrent</FONT>
<BR>
Class SynchronizedVariable</H2>
<PRE>
java.lang.Object
  <IMG SRC="../../../../resources/inherit.gif" ALT="extended by"><B>org.dbunit.util.concurrent.SynchronizedVariable</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../org/dbunit/util/concurrent/Executor.html" title="interface in org.dbunit.util.concurrent">Executor</A></DD>
</DL>
<DL>
<DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../../org/dbunit/util/concurrent/SynchronizedInt.html" title="class in org.dbunit.util.concurrent">SynchronizedInt</A></DD>
</DL>
<HR>
<DL>
<DT>public class <B>SynchronizedVariable</B><DT>extends java.lang.Object<DT>implements <A HREF="../../../../org/dbunit/util/concurrent/Executor.html" title="interface in org.dbunit.util.concurrent">Executor</A></DL>

<P>
Base class for simple,  small classes  maintaining single values that are always accessed and updated under synchronization. Since defining them for only some types seemed too arbitrary, they exist for all basic types, although it is hard to imagine uses for some. <p>   These classes mainly exist so that you do not have to go to the   trouble of writing your own miscellaneous classes and methods   in situations  including:  <ul>   <li> When  you need or want to offload an instance     variable to use its own synchronization lock.    When these objects are used to replace instance variables, they    should almost always be declared as <code>final</code>. This    helps avoid the need to synchronize just to obtain the reference    to the synchronized variable itself.    <li> When you need methods such as set, commit, or swap.    Note however that    the synchronization for these variables is <em>independent</em>    of any other synchronization perfromed using other locks.     So, they are not    normally useful when accesses and updates among     variables must be coordinated.    For example, it would normally be a bad idea to make    a Point class out of two SynchronizedInts, even those    sharing a lock.    <li> When defining <code>static</code> variables. It almost    always works out better to rely on synchronization internal    to these objects, rather  than class locks.  </ul> <p> While they cannot, by nature, share much code, all of these classes work in the same way. <p> <b>Construction</b> <br> Synchronized variables are always constructed holding an initial value of the associated type. Constructors also establish the lock to use for all methods: <ul>   <li> By default, each variable uses itself as the        synchronization lock. This is the most common        choice in the most common usage contexts in which        SynchronizedVariables are used to split off        synchronization locks for independent attributes        of a class.   <li> You can specify any other Object to use as the        synchronization lock. This allows you to        use various forms of `slave synchronization'. For        example, a variable that is always associated with a        particular object can use that object's lock. </ul> <p> <b>Update methods</b><br> Each class supports several kinds of update methods: <ul>   <li> A <code>set</code> method that sets to a new value and returns     previous value. For example, for a SynchronizedBoolean b,    <code>boolean old = b.set(true)</code> performs a test-and-set. <p>   <li> A  <code>commit</code> method that sets to new value only    if currently holding a given value.  For example, here is a class that uses an optimistic update loop to recompute a count variable represented as a  SynchronizedInt.   <pre>  class X {    private final SynchronizedInt count = new SynchronizedInt(0);     static final int MAX_RETRIES = 1000;    public boolean recomputeCount() throws InterruptedException {      for (int i = 0; i &lt; MAX_RETRIES; ++i) {        int current = count.get();        int next = compute(current);        if (count.commit(current, next))          return true;        else if (Thread.interrupted())           throw new InterruptedException();      }      return false;    }    int compute(int l) { ... some kind of computation ...  }  } </pre> <p>   <li>A <code>swap</code> method that atomically swaps with another     object of the same class using a deadlock-avoidance strategy. <p>    <li> Update-in-place methods appropriate to the type. All    numerical types support:     <ul>       <li> add(x) (equivalent to return value += x)       <li> subtract(x) (equivalent to return value -= x)       <li> multiply(x) (equivalent to return value *= x)       <li> divide(x) (equivalent to return value /= x)     </ul>   Integral types also support:     <ul>       <li> increment() (equivalent to return ++value)       <li> decrement() (equivalent to return --value)     </ul>    Boolean types support:     <ul>       <li> or(x) (equivalent to return value |= x)       <li> and(x) (equivalent to return value &amp;= x)       <li> xor(x) (equivalent to return value ^= x)       <li> complement() (equivalent to return x = !x)     </ul>    These cover most, but not all of the possible operators in Java.    You can add more compute-and-set methods in subclasses. This    is often a good way to avoid the need for ad-hoc synchronized    blocks surrounding expressions.  </ul> <p> <b>Guarded methods</b> <br>   All <code>Waitable</code> subclasses provide notifications on   every value update, and support guarded methods of the form   <code>when</code><em>predicate</em>, that wait until the   predicate hold,  then optionally run any Runnable action   within the lock, and then return. All types support:     <ul>       <li> whenEqual(value, action)       <li> whenNotEqual(value, action)     </ul>   (If the action argument is null, these return immediately   after the predicate holds.)   Numerical types also support      <ul>       <li> whenLess(value, action)       <li> whenLessEqual(value, action)       <li> whenGreater(value, action)       <li> whenGreaterEqual(value, action)     </ul>   The Waitable classes are not always spectacularly efficient since they   provide notifications on all value changes.  They are   designed for use in contexts where either performance is not an   overriding issue, or where nearly every update releases guarded   waits anyway.  <p> <b>Other methods</b> <br>   This class implements Executor, and provides an <code>execute</code>   method that runs the runnable within the lock.   <p>   All classes except SynchronizedRef and WaitableRef implement   <code>Cloneable</code> and <code>Comparable</code>.   Implementations of the corresponding   methods either use default mechanics, or use methods that closely   correspond to their java.lang analogs. SynchronizedRef does not

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -