~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qthread.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/corelib/thread/qthread.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QThread Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QThread Class Reference</h1>
 
21
<p>The QThread class provides platform-independent threads. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QThread&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<p>Inherits <a href="qobject.html">QObject</a>.</p>
 
24
<ul>
 
25
<li><a href="qthread-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qthread-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="public-types"></a>
 
29
<h3>Public Types</h3>
 
30
<ul>
 
31
<li><div class="fn"/>enum <b><a href="qthread.html#Priority-enum">Priority</a></b> { IdlePriority, LowestPriority, LowPriority, NormalPriority, ..., InheritPriority }</li>
 
32
</ul>
 
33
<a name="public-functions"></a>
 
34
<h3>Public Functions</h3>
 
35
<ul>
 
36
<li><div class="fn"/><b><a href="qthread.html#QThread">QThread</a></b> ( QObject * <i>parent</i> = 0 )</li>
 
37
<li><div class="fn"/><b><a href="qthread.html#dtor.QThread">~QThread</a></b> ()</li>
 
38
<li><div class="fn"/>void <b><a href="qthread.html#exit">exit</a></b> ( int <i>returnCode</i> = 0 )</li>
 
39
<li><div class="fn"/>bool <b><a href="qthread.html#isFinished">isFinished</a></b> () const</li>
 
40
<li><div class="fn"/>bool <b><a href="qthread.html#isRunning">isRunning</a></b> () const</li>
 
41
<li><div class="fn"/>void <b><a href="qthread.html#setStackSize">setStackSize</a></b> ( uint <i>stackSize</i> )</li>
 
42
<li><div class="fn"/>uint <b><a href="qthread.html#stackSize">stackSize</a></b> () const</li>
 
43
<li><div class="fn"/>bool <b><a href="qthread.html#wait">wait</a></b> ( unsigned long <i>time</i> = ULONG_MAX )</li>
 
44
</ul>
 
45
<ul>
 
46
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
47
</ul>
 
48
<a name="public-slots"></a>
 
49
<h3>Public Slots</h3>
 
50
<ul>
 
51
<li><div class="fn"/>void <b><a href="qthread.html#quit">quit</a></b> ()</li>
 
52
<li><div class="fn"/>void <b><a href="qthread.html#start">start</a></b> ( Priority <i>priority</i> = InheritPriority )</li>
 
53
<li><div class="fn"/>void <b><a href="qthread.html#terminate">terminate</a></b> ()</li>
 
54
</ul>
 
55
<ul>
 
56
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
57
</ul>
 
58
<a name="signals"></a>
 
59
<h3>Signals</h3>
 
60
<ul>
 
61
<li><div class="fn"/>void <b><a href="qthread.html#finished">finished</a></b> ()</li>
 
62
<li><div class="fn"/>void <b><a href="qthread.html#started">started</a></b> ()</li>
 
63
<li><div class="fn"/>void <b><a href="qthread.html#terminated">terminated</a></b> ()</li>
 
64
</ul>
 
65
<ul>
 
66
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
67
</ul>
 
68
<a name="static-public-members"></a>
 
69
<h3>Static Public Members</h3>
 
70
<ul>
 
71
<li><div class="fn"/>QThread * <b><a href="qthread.html#currentThread">currentThread</a></b> ()</li>
 
72
<li><div class="fn"/>Qt::HANDLE <b><a href="qthread.html#currentThreadId">currentThreadId</a></b> ()</li>
 
73
</ul>
 
74
<ul>
 
75
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
76
</ul>
 
77
<a name="protected-functions"></a>
 
78
<h3>Protected Functions</h3>
 
79
<ul>
 
80
<li><div class="fn"/>int <b><a href="qthread.html#exec">exec</a></b> ()</li>
 
81
<li><div class="fn"/>virtual void <b><a href="qthread.html#run">run</a></b> () = 0</li>
 
82
</ul>
 
83
<ul>
 
84
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
85
</ul>
 
86
<a name="static-protected-members"></a>
 
87
<h3>Static Protected Members</h3>
 
88
<ul>
 
89
<li><div class="fn"/>void <b><a href="qthread.html#msleep">msleep</a></b> ( unsigned long <i>msecs</i> )</li>
 
90
<li><div class="fn"/>void <b><a href="qthread.html#setTerminationEnabled">setTerminationEnabled</a></b> ( bool <i>enabled</i> = true )</li>
 
91
<li><div class="fn"/>void <b><a href="qthread.html#sleep">sleep</a></b> ( unsigned long <i>secs</i> )</li>
 
92
<li><div class="fn"/>void <b><a href="qthread.html#usleep">usleep</a></b> ( unsigned long <i>usecs</i> )</li>
 
93
</ul>
 
94
<h3>Additional Inherited Members</h3>
 
95
<ul>
 
96
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
97
</ul>
 
98
<a name="details"></a>
 
99
<hr />
 
100
<h2>Detailed Description</h2>
 
101
<p>The QThread class provides platform-independent threads.</p>
 
102
<p>A QThread represents a separate thread of control within the program; it shares data with all the other threads within the process but executes independently in the way that a separate program does on a multitasking operating system. Instead of starting in <tt>main()</tt>, QThreads begin executing in <a href="qthread.html#run">run</a>(). To create your own threads, subclass QThread and reimplement <a href="qthread.html#run">run</a>(). For example:</p>
 
103
<pre>&nbsp;   class MyThread : public QThread
 
104
    {
 
105
    public:
 
106
        void run();
 
107
    };
 
108
 
 
109
    void MyThread::run()
 
110
    {
 
111
        QTcpSocket socket;
 
112
        // connect QTcpSocket's signals somewhere meaningful
 
113
        ...
 
114
        socket.connectToHost(hostName, portNumber);
 
115
        exec();
 
116
    }</pre>
 
117
<p>This will create a <a href="qtcpsocket.html">QTcpSocket</a> in the thread and then execute the thread's event loop. Use the <a href="qthread.html#start">start</a>() method to begin execution. Execution ends when you return from <a href="qthread.html#run">run</a>(), just as an application does when it leaves main(). QThread will notifiy you via a signal when the thread is <a href="qthread.html#started">started</a>(), <a href="qthread.html#finished">finished</a>(), and <a href="qthread.html#terminated">terminated</a>(), or you can use <a href="qthread.html#isFinished">isFinished</a>() and <a href="qthread.html#isRunning">isRunning</a>() to query the state of the thread. Use <a href="qthread.html#wait">wait</a>() to block until the thread has finished execution.</p>
 
118
<p>Each thread gets its own stack from the operating system. The operating system also determines the default size of the stack. You can use <a href="qthread.html#setStackSize">setStackSize</a>() to set a custom stack size.</p>
 
119
<p>Each QThread can have its own event loop. You can start the event loop by calling <a href="qthread.html#exec">exec</a>(); you can stop it by calling <a href="qthread.html#exit">exit</a>() or <a href="qthread.html#quit">quit</a>(). Having an event loop in a thread makes it possible to connect signals from other threads to slots in this threads, using a mechanism called <a href="qt.html#ConnectionType-enum">queued connections</a>. It also makes it possible to use classes that require the event loop, such as <a href="qtimer.html">QTimer</a> and <a href="qtcpsocket.html">QTcpSocket</a>, in the thread.</p>
 
120
<p>In extreme cases, you may want to forcibly <a href="qthread.html#terminate">terminate</a>() an executing thread. However, doing so is dangerous and discouraged. Please read the documentation for <a href="qthread.html#terminate">terminate</a>() and <a href="qthread.html#setTerminationEnabled">setTerminationEnabled</a>() for detailed information.</p>
 
121
<p>The static functions <a href="qthread.html#currentThreadId">currentThreadId</a>() and <a href="qthread.html#currentThread">currentThread</a>() return identifiers for the currently executing thread. The former returns a platform specific ID for the thread; the latter returns a QThread pointer.</p>
 
122
<p>QThread also provides platform independent sleep functions in varying resolutions. Use <a href="qthread.html#sleep">sleep</a>() for full second resolution, <a href="qthread.html#msleep">msleep</a>() for millisecond resolution, and <a href="qthread.html#usleep">usleep</a>() for microsecond resolution.</p>
 
123
<p>See also <a href="threads.html">Thread Support in Qt</a>, <a href="qthreadstorage.html">QThreadStorage</a>, <a href="qmutex.html">QMutex</a>, <a href="qsemaphore.html">QSemaphore</a>, and <a href="qwaitcondition.html">QWaitCondition</a>.</p>
 
124
<hr />
 
125
<h2>Member Type Documentation</h2>
 
126
<h3 class="fn"><a name="Priority-enum"></a>enum QThread::Priority</h3>
 
127
<p>This enum type indicates how the operating system should schedule newly created threads.</p>
 
128
<table border="1" cellpadding="2" cellspacing="1" width="100%">
 
129
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
 
130
<tr><td valign="top"><tt>QThread::IdlePriority</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">scheduled only when no other threads are running.</td></tr>
 
131
<tr><td valign="top"><tt>QThread::LowestPriority</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">scheduled less often than LowPriority.</td></tr>
 
132
<tr><td valign="top"><tt>QThread::LowPriority</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">scheduled less often than NormalPriority.</td></tr>
 
133
<tr><td valign="top"><tt>QThread::NormalPriority</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">the default priority of the operating system.</td></tr>
 
134
<tr><td valign="top"><tt>QThread::HighPriority</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">scheduled more often than NormalPriority.</td></tr>
 
135
<tr><td valign="top"><tt>QThread::HighestPriority</tt></td><td align="center" valign="top"><tt>5</tt></td><td valign="top">scheduled more often than HighPriority.</td></tr>
 
136
<tr><td valign="top"><tt>QThread::TimeCriticalPriority</tt></td><td align="center" valign="top"><tt>6</tt></td><td valign="top">scheduled as often as possible.</td></tr>
 
137
<tr><td valign="top"><tt>QThread::InheritPriority</tt></td><td align="center" valign="top"><tt>7</tt></td><td valign="top">use the same priority as the creating thread. This is the default.</td></tr>
 
138
</table>
 
139
<hr />
 
140
<h2>Member Function Documentation</h2>
 
141
<h3 class="fn"><a name="QThread"></a>QThread::QThread ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
 
142
<p>Constructs a new thread with the given <i>parent</i>. The thread does not begin executing until <a href="qthread.html#start">start</a>() is called.</p>
 
143
<p>See also <a href="qthread.html#start">start</a>().</p>
 
144
<h3 class="fn"><a name="dtor.QThread"></a>QThread::~QThread ()</h3>
 
145
<p>Destroys the thread.</p>
 
146
<p>Note that deleting a <a href="qthread.html">QThread</a> object will not stop the execution of the thread it represents. Deleting a running <a href="qthread.html">QThread</a> (i.e. <a href="qthread.html#isFinished">isFinished</a>() returns false) will probably result in a program crash. You can <a href="qthread.html#wait">wait</a>() on a thread to make sure that it has finished.</p>
 
147
<h3 class="fn"><a name="currentThread"></a>QThread * QThread::currentThread ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
148
<p>Returns a pointer to the currently executing <a href="qthread.html">QThread</a>. If the current thread was not started using the <a href="qthread.html">QThread</a> API (e.g., the GUI thread), this function returns zero.</p>
 
149
<h3 class="fn"><a name="currentThreadId"></a><a href="qt.html#HANDLE-typedef">Qt::HANDLE</a> QThread::currentThreadId ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
150
<p>Returns the thread handle of the currently executing thread.</p>
 
151
<p><b>Warning:</b> The handle returned by this function is used for internal purposes and should not be used in any application code. On Windows, the returned value is a pseudo-handle for the current thread that cannot be used for numerical comparison.</p>
 
152
<h3 class="fn"><a name="exec"></a>int QThread::exec ()&nbsp;&nbsp;<tt> [protected]</tt></h3>
 
153
<p>Enters the event loop and waits until <a href="qthread.html#exit">exit</a>() is called or the main widget is destroyed, and returns the value that was set to <a href="qthread.html#exit">exit</a>() (which is 0 if <a href="qthread.html#exit">exit</a>() is called via <a href="qthread.html#quit">quit</a>()).</p>
 
154
<p>It is necessary to call this function to start event handling.</p>
 
155
<p>See also <a href="qthread.html#quit">quit</a>() and <a href="qthread.html#exit">exit</a>().</p>
 
156
<h3 class="fn"><a name="exit"></a>void QThread::exit ( int <i>returnCode</i> = 0 )</h3>
 
157
<p>Tells the thread's event loop to exit with a return code.</p>
 
158
<p>After calling this function, the thread leaves the event loop and returns from the call to <a href="qeventloop.html#exec">QEventLoop::exec</a>(). The <a href="qeventloop.html#exec">QEventLoop::exec</a>() function returns <i>returnCode</i>.</p>
 
159
<p>By convention, a <i>returnCode</i> of 0 means success, any non-zero value indicates an error.</p>
 
160
<p>Note that unlike the C library function of the same name, this function <i>does</i> return to the caller -- it is event processing that stops.</p>
 
161
<p>This function does nothing if the thread does not have an event loop.</p>
 
162
<p>See also <a href="qthread.html#quit">quit</a>() and <a href="qeventloop.html">QEventLoop</a>.</p>
 
163
<h3 class="fn"><a name="finished"></a>void QThread::finished ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
164
<p>This signal is emitted when the thread has finished executing.</p>
 
165
<p>See also <a href="qthread.html#started">started</a>() and <a href="qthread.html#terminated">terminated</a>().</p>
 
166
<h3 class="fn"><a name="isFinished"></a>bool QThread::isFinished () const</h3>
 
167
<p>Returns true is the thread is finished; otherwise returns false.</p>
 
168
<p>See also <a href="qthread.html#isRunning">isRunning</a>().</p>
 
169
<h3 class="fn"><a name="isRunning"></a>bool QThread::isRunning () const</h3>
 
170
<p>Returns true if the thread is running; otherwise returns false.</p>
 
171
<p>See also <a href="qthread.html#isFinished">isFinished</a>().</p>
 
172
<h3 class="fn"><a name="msleep"></a>void QThread::msleep ( unsigned long <i>msecs</i> )&nbsp;&nbsp;<tt> [static protected]</tt></h3>
 
173
<p>Causes the current thread to sleep for <i>msecs</i> milliseconds.</p>
 
174
<p>See also <a href="qthread.html#sleep">sleep</a>() and <a href="qthread.html#usleep">usleep</a>().</p>
 
175
<h3 class="fn"><a name="quit"></a>void QThread::quit ()&nbsp;&nbsp;<tt> [slot]</tt></h3>
 
176
<p>Tells the thread's event loop to exit with return code 0 (success). Equivalent to calling QThread::exit(0).</p>
 
177
<p>This function does nothing if the thread does not have an event loop.</p>
 
178
<p>See also <a href="qthread.html#exit">exit</a>() and <a href="qeventloop.html">QEventLoop</a>.</p>
 
179
<h3 class="fn"><a name="run"></a>void QThread::run ()&nbsp;&nbsp;<tt> [pure virtual protected]</tt></h3>
 
180
<p>This method is pure virtual and must be implemented in derived classes in order to do useful work. Returning from this method will end the execution of the thread.</p>
 
181
<p>See also <a href="qthread.html#wait">wait</a>().</p>
 
182
<h3 class="fn"><a name="setStackSize"></a>void QThread::setStackSize ( <a href="qtglobal.html#uint-typedef">uint</a> <i>stackSize</i> )</h3>
 
183
<p>Sets the maximum stack size for the thread to <i>stackSize</i>. If <i>stackSize</i> is greater than zero, the maximum stack size is set to <i>stackSize</i> bytes, otherwise the maximum stack size is automatically determined by the operating system.</p>
 
184
<p><b>Warning:</b> Most operating systems place minimum and maximum limits on thread stack sizes. The thread will fail to start if the stack size is outside these limits.</p>
 
185
<p>See also <a href="qthread.html#stackSize">stackSize</a>().</p>
 
186
<h3 class="fn"><a name="setTerminationEnabled"></a>void QThread::setTerminationEnabled ( bool <i>enabled</i> = true )&nbsp;&nbsp;<tt> [static protected]</tt></h3>
 
187
<p>Enables or disables termination of the current thread based on the <i>enabled</i> parameter. The thread must have been started by <a href="qthread.html">QThread</a>.</p>
 
188
<p>When <i>enabled</i> is false, termination is disabled. Future calls to <a href="qthread.html#terminate">QThread::terminate</a>() will return immediately without effect. Instead, the termination is deferred until termination is enabled.</p>
 
189
<p>When <i>enabled</i> is true, termination is enabled. Future calls to <a href="qthread.html#terminate">QThread::terminate</a>() will terminate the thread normally. If termination has been deferred (i.e. <a href="qthread.html#terminate">QThread::terminate</a>() was called with termination disabled), this function will terminate the calling thread <i>immediately</i>. Note that this function will not return in this case.</p>
 
190
<p>See also <a href="qthread.html#terminate">terminate</a>().</p>
 
191
<h3 class="fn"><a name="sleep"></a>void QThread::sleep ( unsigned long <i>secs</i> )&nbsp;&nbsp;<tt> [static protected]</tt></h3>
 
192
<p>Forces the current thread to sleep for <i>secs</i> seconds.</p>
 
193
<p>See also <a href="qthread.html#msleep">msleep</a>() and <a href="qthread.html#usleep">usleep</a>().</p>
 
194
<h3 class="fn"><a name="stackSize"></a><a href="qtglobal.html#uint-typedef">uint</a> QThread::stackSize () const</h3>
 
195
<p>Returns the maximum stack size for the thread (if set with <a href="qthread.html#setStackSize">setStackSize</a>()); otherwise returns zero.</p>
 
196
<p>See also <a href="qthread.html#setStackSize">setStackSize</a>().</p>
 
197
<h3 class="fn"><a name="start"></a>void QThread::start ( <a href="qthread.html#Priority-enum">Priority</a> <i>priority</i> = InheritPriority )&nbsp;&nbsp;<tt> [slot]</tt></h3>
 
198
<p>Begins execution of the thread by calling <a href="qthread.html#run">run</a>(), which should be reimplemented in a <a href="qthread.html">QThread</a> subclass to contain your code. The operating system will schedule the thread according to the <i>priority</i> parameter. If the thread is already running, this function does nothing.</p>
 
199
<p>See also <a href="qthread.html#run">run</a>() and <a href="qthread.html#terminate">terminate</a>().</p>
 
200
<h3 class="fn"><a name="started"></a>void QThread::started ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
201
<p>This signal is emitted when the thread starts executing.</p>
 
202
<p>See also <a href="qthread.html#finished">finished</a>() and <a href="qthread.html#terminated">terminated</a>().</p>
 
203
<h3 class="fn"><a name="terminate"></a>void QThread::terminate ()&nbsp;&nbsp;<tt> [slot]</tt></h3>
 
204
<p>Terminates the execution of the thread. The thread may or may not be terminated immediately, depending on the operating systems scheduling policies. Use <a href="qthread.html#wait">QThread::wait</a>() after terminate() for synchronous termination.</p>
 
205
<p>When the thread is terminated, all threads waiting for the thread to finish will be woken up.</p>
 
206
<p><b>Warning:</b> This function is dangerous and its use is discouraged. The thread can be terminate at any point in its code path. Threads can be terminated while modifying data. There is no chance for the thread to cleanup after itself, unlock any held mutexes, etc. In short, use this function only if absolutely necessary.</p>
 
207
<p>Termination can be explicitly enabled or disabled by calling <a href="qthread.html#setTerminationEnabled">QThread::setTerminationEnabled</a>(). Calling this function while termination is disabled results in the termination being deferred, until termination is re-enabled. See the documentation of <a href="qthread.html#setTerminationEnabled">QThread::setTerminationEnabled</a>() for more information.</p>
 
208
<p>See also <a href="qthread.html#setTerminationEnabled">setTerminationEnabled</a>().</p>
 
209
<h3 class="fn"><a name="terminated"></a>void QThread::terminated ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
210
<p>This signal is emitted when the thread is terminated.</p>
 
211
<p>See also <a href="qthread.html#started">started</a>() and <a href="qthread.html#finished">finished</a>().</p>
 
212
<h3 class="fn"><a name="usleep"></a>void QThread::usleep ( unsigned long <i>usecs</i> )&nbsp;&nbsp;<tt> [static protected]</tt></h3>
 
213
<p>Causes the current thread to sleep for <i>usecs</i> microseconds.</p>
 
214
<p>See also <a href="qthread.html#sleep">sleep</a>() and <a href="qthread.html#msleep">msleep</a>().</p>
 
215
<h3 class="fn"><a name="wait"></a>bool QThread::wait ( unsigned long <i>time</i> = ULONG_MAX )</h3>
 
216
<p>Blocks the thread until either of these conditions is met:</p>
 
217
<ul>
 
218
<li>The thread associated with this <a href="qthread.html">QThread</a> object has finished execution (i.e. when it returns from <a href="qthread.html#run">run</a>()). This function will return true if the thread has finished. It also returns true if the thread has not been started yet.</li>
 
219
<li><i>time</i> milliseconds has elapsed. If <i>time</i> is ULONG_MAX (the default), then the wait will never timeout (the thread must return from <a href="qthread.html#run">run</a>()). This function will return false if the wait timed out.</li>
 
220
</ul>
 
221
<p>This provides similar functionality to the POSIX <tt>pthread_join()</tt> function.</p>
 
222
<p>See also <a href="qthread.html#sleep">sleep</a>() and <a href="qthread.html#terminate">terminate</a>().</p>
 
223
<p /><address><hr /><div align="center">
 
224
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
225
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
226
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
227
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
228
</tr></table></div></address></body>
 
229
</html>