65 lines
4.8 KiB
HTML
65 lines
4.8 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="concept" />
|
|
<meta name="DC.Title" content="One-time initialization and thread safety" />
|
|
<meta name="abstract" content="At times, you might want to defer the initialization of resources until a thread requires them. However, your application might require that multiple threads use a certain resource, which requires you to initialize the resource only once in a threadsafe way." />
|
|
<meta name="description" content="At times, you might want to defer the initialization of resources until a thread requires them. However, your application might require that multiple threads use a certain resource, which requires you to initialize the resource only once in a threadsafe way." />
|
|
<meta name="DC.Relation" scheme="URI" content="rzahwmulco.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzahwe15rx.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzahwe16rx.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzahwdatco.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzahwnonco.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzahwcomco.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="rzahwone-oneco" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>One-time initialization and thread safety</title>
|
|
</head>
|
|
<body id="rzahwone-oneco"><a name="rzahwone-oneco"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">One-time initialization and thread safety</h1>
|
|
<div><p>At times, you might want to defer the initialization of resources
|
|
until a thread requires them. However, your application might require that
|
|
multiple threads use a certain resource, which requires you to initialize
|
|
the resource only once in a threadsafe way.</p>
|
|
<p>There are several ways you can initialize a resource that is used multiple
|
|
times in a threadsafe fashion. Most of these methods involve a Boolean
|
|
value to allow the application to quickly determine whether the required initialization
|
|
is completed. You must also use a synchronization technique in addition to
|
|
the Boolean flag to ensure that the initialization completed.</p>
|
|
</div>
|
|
<div>
|
|
<ul class="ullinks">
|
|
<li class="ulchildlink"><strong><a href="rzahwe15rx.htm">Example: One-time initialization in Pthread programs</a></strong><br />
|
|
This example shows a Pthread program that is dynamically initializing an integer using the Pthread one time initialization support.</li>
|
|
</ul>
|
|
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahwmulco.htm" title="If you are going to write multithreaded applications or server applications for i5/OS, you should be familiar with several techniques.">Multithreaded programming techniques</a></div>
|
|
</div>
|
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="rzahwnonco.htm" title="Your multithreaded application at times requires access to functions or system services that are not thread safe. There are few completely safe alternatives for calling these functions.">Function calls that are not thread safe</a></div>
|
|
<div><a href="rzahwcomco.htm" title="Several programming errors often occur when writing multithreaded applications.">Common multithreaded programming errors</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="rzahwe16rx.htm" title="This example shows a Pthread program that is dynamically initializing an integer using the space location lock synchronization primitive.">Example: Space location locks in Pthread programs</a></div>
|
|
<div><a href="rzahwdatco.htm" title="Typical applications that are not threaded use global storage.">Thread-specific data</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |