ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahw_5.4.0.1/rzahwcanco.htm

70 lines
5.1 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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="Cancel a thread" />
<meta name="abstract" content="The ability to end a thread externally allows you to cancel threads that run long requests before they are completed on their own. The methods available for canceling threads vary according to the threads API set that is used." />
<meta name="description" content="The ability to end a thread externally allows you to cancel threads that run long requests before they are completed on their own. The methods available for canceling threads vary according to the threads API set that is used." />
<meta name="DC.Relation" scheme="URI" content="rzahwtwoco.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahwe12rx.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahwex8rx.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahwsusco.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahwresco.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="rzahwcan-canco" />
<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>Cancel a thread</title>
</head>
<body id="rzahwcan-canco"><a name="rzahwcan-canco"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Cancel a thread</h1>
<div><p>The ability to end a thread externally allows you to cancel threads
that run long requests before they are completed on their own. The methods
available for canceling threads vary according to the threads API set that
is used.</p>
<p>Some API sets provide well-defined points for the cancelation action to
occur or other mechanisms that allow one thread to control when another thread
ends. Some API sets also provide a mechanism to run cleanup code before the
thread ends or to set the result of the canceled thread to a specific value.</p>
<p>Use thread cancelation carefully. If your API set does not provide well-defined
cancelation points or a mechanism for the thread to clean up the application
data and locks, you might damage data or cause deadlocks within your application.</p>
<div class="note"><span class="notetitle">Note:</span> In Java™ Development Kit version 1.2 or later,
the resume, stop, and suspend methods for the thread class have been deprecated.
This is because these methods are considered unsafe. The functions provided
by these methods can be implemented by other mechanisms, such as checking
the state of some variables. See the Sun Java tutorial at <a href="http://java.sun.com/docs/books/tutorial/" target="_blank">http://java.sun.com/docs/books/tutorial/</a> <img src="www.gif" alt="Link outside information center" /> for the recommended
mechanism for a given version of Java.</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzahwe12rx.htm">Example: Cancel a thread in a Pthread program</a></strong><br />
This example shows a Pthread program canceling a long-running thread.</li>
<li class="ulchildlink"><strong><a href="rzahwex8rx.htm">Example: Cancel a thread using Java</a></strong><br />
This example shows a Java program canceling a long-running thread.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahwtwoco.htm" title="The concepts described here pertain to all programming languages.">i5/OS thread management</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rzahwsusco.htm" title="It is sometimes useful to stop a thread temporarily from processing in your application. When you suspend a thread, the state of the thread, including all the attributes and locks held by the thread, is maintained until that thread is resumed.">Suspend a thread</a></div>
<div><a href="rzahwresco.htm" title="If you temporarily stopped a thread from processing in your application, you can resume the processing of the suspended thread at a later time at the same point that you suspended it.">Resume a thread</a></div>
</div>
</div>
</body>
</html>