• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/db-4.7.25.NC/docs/gsg_txn/JAVA/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Chapter��4.��Concurrency</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.62.4" />
9    <link rel="home" href="index.html" title="Getting Started with Berkeley DB Transaction Processing" />
10    <link rel="up" href="index.html" title="Getting Started with Berkeley DB Transaction Processing" />
11    <link rel="previous" href="maxtxns.html" title="Configuring the Transaction Subsystem" />
12    <link rel="next" href="blocking_deadlocks.html" title="Locks, Blocks, and Deadlocks" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Chapter��4.��Concurrency</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="maxtxns.html">Prev</a>��</td>
22          <th width="60%" align="center">��</th>
23          <td width="20%" align="right">��<a accesskey="n" href="blocking_deadlocks.html">Next</a></td>
24        </tr>
25      </table>
26      <hr />
27    </div>
28    <div class="chapter" lang="en" xml:lang="en">
29      <div class="titlepage">
30        <div>
31          <div>
32            <h2 class="title"><a id="txnconcurrency"></a>Chapter��4.��Concurrency</h2>
33          </div>
34        </div>
35        <div></div>
36      </div>
37      <div class="toc">
38        <p>
39          <b>Table of Contents</b>
40        </p>
41        <dl>
42          <dt>
43            <span class="sect1">
44              <a href="txnconcurrency.html#concurrenthandles">Which DB Handles are Free-Threaded</a>
45            </span>
46          </dt>
47          <dt>
48            <span class="sect1">
49              <a href="blocking_deadlocks.html">Locks, Blocks, and Deadlocks</a>
50            </span>
51          </dt>
52          <dd>
53            <dl>
54              <dt>
55                <span class="sect2">
56                  <a href="blocking_deadlocks.html#locks">Locks</a>
57                </span>
58              </dt>
59              <dt>
60                <span class="sect2">
61                  <a href="blocking_deadlocks.html#blocks">Blocks</a>
62                </span>
63              </dt>
64              <dt>
65                <span class="sect2">
66                  <a href="blocking_deadlocks.html#deadlocks">Deadlocks</a>
67                </span>
68              </dt>
69            </dl>
70          </dd>
71          <dt>
72            <span class="sect1">
73              <a href="lockingsubsystem.html">The Locking Subsystem</a>
74            </span>
75          </dt>
76          <dd>
77            <dl>
78              <dt>
79                <span class="sect2">
80                  <a href="lockingsubsystem.html#configuringlock">Configuring the Locking Subsystem</a>
81                </span>
82              </dt>
83              <dt>
84                <span class="sect2">
85                  <a href="lockingsubsystem.html#configdeadlkdetect">Configuring Deadlock Detection</a>
86                </span>
87              </dt>
88              <dt>
89                <span class="sect2">
90                  <a href="lockingsubsystem.html#deadlockresolve">Resolving Deadlocks</a>
91                </span>
92              </dt>
93            </dl>
94          </dd>
95          <dt>
96            <span class="sect1">
97              <a href="isolation.html">Isolation</a>
98            </span>
99          </dt>
100          <dd>
101            <dl>
102              <dt>
103                <span class="sect2">
104                  <a href="isolation.html#degreesofisolation">Supported Degrees of Isolation</a>
105                </span>
106              </dt>
107              <dt>
108                <span class="sect2">
109                  <a href="isolation.html#dirtyreads">Reading Uncommitted Data</a>
110                </span>
111              </dt>
112              <dt>
113                <span class="sect2">
114                  <a href="isolation.html#readcommitted">Committed Reads</a>
115                </span>
116              </dt>
117              <dt>
118                <span class="sect2">
119                  <a href="isolation.html#snapshot_isolation">Using Snapshot Isolation</a>
120                </span>
121              </dt>
122            </dl>
123          </dd>
124          <dt>
125            <span class="sect1">
126              <a href="txn_ccursor.html">Transactional Cursors and Concurrent Applications</a>
127            </span>
128          </dt>
129          <dd>
130            <dl>
131              <dt>
132                <span class="sect2">
133                  <a href="txn_ccursor.html#cursordirtyreads">Using Cursors with Uncommitted Data</a>
134                </span>
135              </dt>
136            </dl>
137          </dd>
138          <dt>
139            <span class="sect1">
140              <a href="readmodifywrite.html">Read/Modify/Write</a>
141            </span>
142          </dt>
143          <dt>
144            <span class="sect1">
145              <a href="txnnowait.html">No Wait on Blocks</a>
146            </span>
147          </dt>
148          <dt>
149            <span class="sect1">
150              <a href="reversesplit.html">Reverse BTree Splits</a>
151            </span>
152          </dt>
153        </dl>
154      </div>
155      <p>
156
157        DB offers a great deal of support for multi-threaded
158            <span>
159                and multi-process
160            </span>
161        applications even when transactions are not in use. Many of DB's
162        handles are 
163        thread-safe<span>, or 
164        can be made thread-safe by providing the appropriate flag at handle creation time,</span> 
165        and DB provides a
166        flexible locking subsystem for managing databases in a concurrent
167        application. Further, DB provides a robust mechanism for
168        detecting and responding to deadlocks. All of these concepts are
169        explored in this chapter.
170     </p>
171      <p>
172        Before continuing, it is useful to define a few terms that will appear
173        throughout this chapter:
174     </p>
175      <div class="itemizedlist">
176        <ul type="disc">
177          <li>
178            <p>
179                <span class="emphasis"><em>Thread of control</em></span>
180            </p>
181            <p>
182                Refers to a thread that is performing work in your application.
183                Typically, in this book that thread will be performing DB
184                operations.
185            </p>
186            <p>
187                Note that this term can also be taken to mean a separate process
188                that is performing work ��� DB supports multi-process
189                operations on your databases.
190            </p>
191          </li>
192          <li>
193            <p>
194                <span class="emphasis"><em>Locking</em></span>
195            </p>
196            <p>
197                When a thread of control obtains 
198                access to a shared resource, it is said to be
199                <span class="emphasis"><em>locking</em></span> that resource. Note that
200                DB supports both exclusive and non-exclusive locks. See
201                <a href="blocking_deadlocks.html#locks">Locks</a> for more information.
202            </p>
203          </li>
204          <li>
205            <p>
206                <span class="emphasis"><em>Free-threaded</em></span>
207            </p>
208            <p>
209                Data structures and objects are free-threaded if they can be
210                shared across threads of control without any explicit locking on
211                the part of the application.  Some books, libraries, and
212                programming languages may use the term
213                <span class="emphasis"><em>thread-safe</em></span> for data structures or objects
214                that have this characteristic. The two terms mean the
215                same thing.
216            </p>
217            <p>
218                For a description of free-threaded DB objects, see
219                <a href="txnconcurrency.html#concurrenthandles">Which DB Handles are Free-Threaded</a>.
220            </p>
221          </li>
222          <li>
223            <p>
224                <span class="emphasis"><em>Blocked</em></span>
225            </p>
226            <p>
227                When a thread cannot obtain a lock because some other
228                thread already holds a lock on that object, the lock
229                attempt is said to be <span class="emphasis"><em>blocked</em></span>. See
230                <a href="blocking_deadlocks.html#blocks">Blocks</a> for more information.
231            </p>
232          </li>
233          <li>
234            <p>
235                <span class="emphasis"><em>Deadlock</em></span>
236            </p>
237            <p>
238                Occurs when two or more threads of control attempt to access conflicting resource in such a way as none
239                of the threads can any longer may further progress.
240            </p>
241            <p>
242                For example, if Thread A is blocked waiting for a resource held by Thread
243                B, while at the same time Thread B is blocked waiting for a
244                resource held by Thread A, then neither thread can make any
245                forward progress. In this situation, Thread A and Thread B
246                are said to be <span class="emphasis"><em>deadlocked.</em></span>
247            </p>
248            <p>
249                For more information, see <a href="blocking_deadlocks.html#deadlocks">Deadlocks</a>.
250            </p>
251          </li>
252        </ul>
253      </div>
254      <div class="sect1" lang="en" xml:lang="en">
255        <div class="titlepage">
256          <div>
257            <div>
258              <h2 class="title" style="clear: both"><a id="concurrenthandles"></a>Which DB Handles are Free-Threaded</h2>
259            </div>
260          </div>
261          <div></div>
262        </div>
263        <p>
264            The following describes to what extent and under what conditions
265            individual handles are free-threaded.
266        </p>
267        <div class="itemizedlist">
268          <ul type="disc">
269            <li>
270              <p>
271                    
272                    
273                   <tt class="classname">Environment</tt> 
274                </p>
275              <p>
276                    Free-threaded so long as
277                        
278                        <span>
279                            <tt class="methodname">EnvironmentConfig.setThreaded()</tt>
280                            is set to <tt class="literal">true</tt>.
281                        </span>
282                </p>
283            </li>
284            <li>
285              <p>
286                    
287                    
288                   <tt class="classname">Database</tt> 
289                </p>
290              <p>
291                    Free-threaded so long as
292                        
293                        <span>
294                            the database is opened in a free-threaded environment.
295                        </span>
296                </p>
297            </li>
298            <li>
299              <p>
300                   <tt class="classname">SecondaryDatabase</tt> 
301                </p>
302              <p>
303                    Same conditions apply as for <tt class="classname">Database</tt>
304                    handles.
305                </p>
306            </li>
307            <li>
308              <p>
309                    
310                    
311                   <tt class="classname">Cursor</tt> 
312                </p>
313              <p>
314                    Cursors are not free-threaded. However, they
315                    can be used by multiple threads of control so 
316                    long as the application serializes access to the handle.
317                </p>
318            </li>
319            <li>
320              <p>
321                   <tt class="classname">SecondaryCursor</tt> 
322                </p>
323              <p>
324                    Same conditions apply as for <tt class="classname">Cursor</tt>
325                    handles.
326                </p>
327            </li>
328            <li>
329              <p>
330                    
331                    
332                   <tt class="classname">Transaction</tt> 
333                    
334                </p>
335              <p>
336                    Access must be serialized by the application across threads of control.
337                </p>
338            </li>
339          </ul>
340        </div>
341        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
342          <h3 class="title">Note</h3>
343          <p>
344                All classes found in the DPL (<tt class="literal">com.sleepycat.persist.*</tt>) are free-threaded.
345            </p>
346          <p>
347                All classes found in the bind APIs (<tt class="literal">com.sleepycat.bind.*</tt>) are free-threaded.
348            </p>
349        </div>
350      </div>
351    </div>
352    <div class="navfooter">
353      <hr />
354      <table width="100%" summary="Navigation footer">
355        <tr>
356          <td width="40%" align="left"><a accesskey="p" href="maxtxns.html">Prev</a>��</td>
357          <td width="20%" align="center">
358            <a accesskey="u" href="index.html">Up</a>
359          </td>
360          <td width="40%" align="right">��<a accesskey="n" href="blocking_deadlocks.html">Next</a></td>
361        </tr>
362        <tr>
363          <td width="40%" align="left" valign="top">Configuring the Transaction Subsystem��</td>
364          <td width="20%" align="center">
365            <a accesskey="h" href="index.html">Home</a>
366          </td>
367          <td width="40%" align="right" valign="top">��Locks, Blocks, and Deadlocks</td>
368        </tr>
369      </table>
370    </div>
371  </body>
372</html>
373