home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n Module| \sectco|
|00000020| 64 65 7b 74 68 72 65 61 | 64 7d 7d 0a 5c 62 69 6d |de{threa|d}}.\bim|
|00000030| 6f 64 69 6e 64 65 78 7b | 74 68 72 65 61 64 7d 0a |odindex{|thread}.|
|00000040| 0a 54 68 69 73 20 6d 6f | 64 75 6c 65 20 70 72 6f |.This mo|dule pro|
|00000050| 76 69 64 65 73 20 6c 6f | 77 2d 6c 65 76 65 6c 20 |vides lo|w-level |
|00000060| 70 72 69 6d 69 74 69 76 | 65 73 20 66 6f 72 20 77 |primitiv|es for w|
|00000070| 6f 72 6b 69 6e 67 20 77 | 69 74 68 20 6d 75 6c 74 |orking w|ith mult|
|00000080| 69 70 6c 65 0a 74 68 72 | 65 61 64 73 20 28 61 2e |iple.thr|eads (a.|
|00000090| 6b 2e 61 2e 5c 20 5c 64 | 66 6e 7b 6c 69 67 68 74 |k.a.\ \d|fn{light|
|000000a0| 2d 77 65 69 67 68 74 20 | 70 72 6f 63 65 73 73 65 |-weight |processe|
|000000b0| 73 7d 20 6f 72 20 5c 64 | 66 6e 7b 74 61 73 6b 73 |s} or \d|fn{tasks|
|000000c0| 7d 29 20 2d 2d 2d 20 6d | 75 6c 74 69 70 6c 65 0a |}) --- m|ultiple.|
|000000d0| 74 68 72 65 61 64 73 20 | 6f 66 20 63 6f 6e 74 72 |threads |of contr|
|000000e0| 6f 6c 20 73 68 61 72 69 | 6e 67 20 74 68 65 69 72 |ol shari|ng their|
|000000f0| 20 67 6c 6f 62 61 6c 20 | 64 61 74 61 20 73 70 61 | global |data spa|
|00000100| 63 65 2e 20 20 46 6f 72 | 0a 73 79 6e 63 68 72 6f |ce. For|.synchro|
|00000110| 6e 69 7a 61 74 69 6f 6e | 2c 20 73 69 6d 70 6c 65 |nization|, simple|
|00000120| 20 6c 6f 63 6b 73 20 28 | 61 2e 6b 2e 61 2e 5c 20 | locks (|a.k.a.\ |
|00000130| 5c 64 66 6e 7b 6d 75 74 | 65 78 65 73 7d 20 6f 72 |\dfn{mut|exes} or|
|00000140| 20 5c 64 66 6e 7b 62 69 | 6e 61 72 79 0a 73 65 6d | \dfn{bi|nary.sem|
|00000150| 61 70 68 6f 72 65 73 7d | 29 20 61 72 65 20 70 72 |aphores}|) are pr|
|00000160| 6f 76 69 64 65 64 2e 0a | 0a 54 68 65 20 6d 6f 64 |ovided..|.The mod|
|00000170| 75 6c 65 20 69 73 20 6f | 70 74 69 6f 6e 61 6c 20 |ule is o|ptional |
|00000180| 61 6e 64 20 73 75 70 70 | 6f 72 74 65 64 20 6f 6e |and supp|orted on|
|00000190| 20 53 47 49 20 49 52 49 | 58 20 34 2e 78 20 61 6e | SGI IRI|X 4.x an|
|000001a0| 64 20 35 2e 78 20 61 6e | 64 20 53 75 6e 0a 53 6f |d 5.x an|d Sun.So|
|000001b0| 6c 61 72 69 73 20 32 2e | 78 20 73 79 73 74 65 6d |laris 2.|x system|
|000001c0| 73 2c 20 61 73 20 77 65 | 6c 6c 20 61 73 20 6f 6e |s, as we|ll as on|
|000001d0| 20 73 79 73 74 65 6d 73 | 20 74 68 61 74 20 68 61 | systems| that ha|
|000001e0| 76 65 20 61 20 50 54 48 | 52 45 41 44 0a 69 6d 70 |ve a PTH|READ.imp|
|000001f0| 6c 65 6d 65 6e 74 61 74 | 69 6f 6e 20 28 65 2e 67 |lementat|ion (e.g|
|00000200| 2e 5c 20 4b 53 52 29 2e | 0a 0a 49 74 20 64 65 66 |.\ KSR).|..It def|
|00000210| 69 6e 65 73 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |ines the| followi|
|00000220| 6e 67 20 63 6f 6e 73 74 | 61 6e 74 20 61 6e 64 20 |ng const|ant and |
|00000230| 66 75 6e 63 74 69 6f 6e | 73 3a 0a 0a 5c 72 65 6e |function|s:..\ren|
|00000240| 65 77 63 6f 6d 6d 61 6e | 64 7b 5c 69 6e 64 65 78 |ewcomman|d{\index|
|00000250| 73 75 62 69 74 65 6d 7d | 7b 28 69 6e 20 6d 6f 64 |subitem}|{(in mod|
|00000260| 75 6c 65 20 74 68 72 65 | 61 64 29 7d 0a 5c 62 65 |ule thre|ad)}.\be|
|00000270| 67 69 6e 7b 65 78 63 64 | 65 73 63 7d 7b 65 72 72 |gin{excd|esc}{err|
|00000280| 6f 72 7d 0a 52 61 69 73 | 65 64 20 6f 6e 20 74 68 |or}.Rais|ed on th|
|00000290| 72 65 61 64 2d 73 70 65 | 63 69 66 69 63 20 65 72 |read-spe|cific er|
|000002a0| 72 6f 72 73 2e 0a 5c 65 | 6e 64 7b 65 78 63 64 65 |rors..\e|nd{excde|
|000002b0| 73 63 7d 0a 0a 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|000002c0| 64 65 73 63 7d 7b 73 74 | 61 72 74 5f 6e 65 77 5f |desc}{st|art_new_|
|000002d0| 74 68 72 65 61 64 7d 7b | 66 75 6e 63 5c 2c 20 61 |thread}{|func\, a|
|000002e0| 72 67 7d 0a 53 74 61 72 | 74 20 61 20 6e 65 77 20 |rg}.Star|t a new |
|000002f0| 74 68 72 65 61 64 2e 20 | 20 54 68 65 20 74 68 72 |thread. | The thr|
|00000300| 65 61 64 20 65 78 65 63 | 75 74 65 73 20 74 68 65 |ead exec|utes the|
|00000310| 20 66 75 6e 63 74 69 6f | 6e 20 5c 76 61 72 7b 66 | functio|n \var{f|
|00000320| 75 6e 63 7d 0a 77 69 74 | 68 20 74 68 65 20 61 72 |unc}.wit|h the ar|
|00000330| 67 75 6d 65 6e 74 20 6c | 69 73 74 20 5c 76 61 72 |gument l|ist \var|
|00000340| 7b 61 72 67 7d 20 28 77 | 68 69 63 68 20 6d 75 73 |{arg} (w|hich mus|
|00000350| 74 20 62 65 20 61 20 74 | 75 70 6c 65 29 2e 20 20 |t be a t|uple). |
|00000360| 57 68 65 6e 20 74 68 65 | 0a 66 75 6e 63 74 69 6f |When the|.functio|
|00000370| 6e 20 72 65 74 75 72 6e | 73 2c 20 74 68 65 20 74 |n return|s, the t|
|00000380| 68 72 65 61 64 20 73 69 | 6c 65 6e 74 6c 79 20 65 |hread si|lently e|
|00000390| 78 69 74 73 2e 20 20 57 | 68 65 6e 20 74 68 65 20 |xits. W|hen the |
|000003a0| 66 75 6e 63 74 69 6f 6e | 0a 74 65 72 6d 69 6e 61 |function|.termina|
|000003b0| 74 65 73 20 77 69 74 68 | 20 61 6e 20 75 6e 68 61 |tes with| an unha|
|000003c0| 6e 64 6c 65 64 20 65 78 | 63 65 70 74 69 6f 6e 2c |ndled ex|ception,|
|000003d0| 20 61 20 73 74 61 63 6b | 20 74 72 61 63 65 20 69 | a stack| trace i|
|000003e0| 73 20 70 72 69 6e 74 65 | 64 20 61 6e 64 0a 74 68 |s printe|d and.th|
|000003f0| 65 6e 20 74 68 65 20 74 | 68 72 65 61 64 20 65 78 |en the t|hread ex|
|00000400| 69 74 73 20 28 62 75 74 | 20 6f 74 68 65 72 20 74 |its (but| other t|
|00000410| 68 72 65 61 64 73 20 63 | 6f 6e 74 69 6e 75 65 20 |hreads c|ontinue |
|00000420| 74 6f 20 72 75 6e 29 2e | 0a 5c 65 6e 64 7b 66 75 |to run).|.\end{fu|
|00000430| 6e 63 64 65 73 63 7d 0a | 0a 5c 62 65 67 69 6e 7b |ncdesc}.|.\begin{|
|00000440| 66 75 6e 63 64 65 73 63 | 7d 7b 65 78 69 74 7d 7b |funcdesc|}{exit}{|
|00000450| 7d 0a 54 68 69 73 20 69 | 73 20 61 20 73 68 6f 72 |}.This i|s a shor|
|00000460| 74 68 61 6e 64 20 66 6f | 72 20 5c 63 6f 64 65 7b |thand fo|r \code{|
|00000470| 74 68 72 65 61 64 2e 65 | 78 69 74 5f 74 68 72 65 |thread.e|xit_thre|
|00000480| 61 64 28 29 7d 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |ad()}..\|end{func|
|00000490| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|000004a0| 6e 63 64 65 73 63 7d 7b | 65 78 69 74 5f 74 68 72 |ncdesc}{|exit_thr|
|000004b0| 65 61 64 7d 7b 7d 0a 52 | 61 69 73 65 20 74 68 65 |ead}{}.R|aise the|
|000004c0| 20 5c 63 6f 64 65 7b 53 | 79 73 74 65 6d 45 78 69 | \code{S|ystemExi|
|000004d0| 74 7d 20 65 78 63 65 70 | 74 69 6f 6e 2e 20 20 57 |t} excep|tion. W|
|000004e0| 68 65 6e 20 6e 6f 74 20 | 63 61 75 67 68 74 2c 20 |hen not |caught, |
|000004f0| 74 68 69 73 20 77 69 6c | 6c 0a 63 61 75 73 65 20 |this wil|l.cause |
|00000500| 74 68 65 20 74 68 72 65 | 61 64 20 74 6f 20 65 78 |the thre|ad to ex|
|00000510| 69 74 20 73 69 6c 65 6e | 74 6c 79 2e 0a 5c 65 6e |it silen|tly..\en|
|00000520| 64 7b 66 75 6e 63 64 65 | 73 63 7d 0a 0a 25 5c 62 |d{funcde|sc}..%\b|
|00000530| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 65 |egin{fun|cdesc}{e|
|00000540| 78 69 74 5f 70 72 6f 67 | 7d 7b 73 74 61 74 75 73 |xit_prog|}{status|
|00000550| 7d 0a 25 45 78 69 74 20 | 61 6c 6c 20 74 68 72 65 |}.%Exit |all thre|
|00000560| 61 64 73 20 61 6e 64 20 | 72 65 70 6f 72 74 20 74 |ads and |report t|
|00000570| 68 65 20 76 61 6c 75 65 | 20 6f 66 20 74 68 65 20 |he value| of the |
|00000580| 69 6e 74 65 67 65 72 20 | 61 72 67 75 6d 65 6e 74 |integer |argument|
|00000590| 0a 25 5c 76 61 72 7b 73 | 74 61 74 75 73 7d 20 61 |.%\var{s|tatus} a|
|000005a0| 73 20 74 68 65 20 65 78 | 69 74 20 73 74 61 74 75 |s the ex|it statu|
|000005b0| 73 20 6f 66 20 74 68 65 | 20 65 6e 74 69 72 65 20 |s of the| entire |
|000005c0| 70 72 6f 67 72 61 6d 2e | 0a 25 5c 73 74 72 6f 6e |program.|.%\stron|
|000005d0| 67 7b 43 61 76 65 61 74 | 3a 7d 20 63 6f 64 65 20 |g{Caveat|:} code |
|000005e0| 69 6e 20 70 65 6e 64 69 | 6e 67 20 5c 63 6f 64 65 |in pendi|ng \code|
|000005f0| 7b 66 69 6e 61 6c 6c 79 | 7d 20 63 6c 61 75 73 65 |{finally|} clause|
|00000600| 73 2c 20 69 6e 20 74 68 | 69 73 20 74 68 72 65 61 |s, in th|is threa|
|00000610| 64 0a 25 6f 72 20 69 6e | 20 6f 74 68 65 72 20 74 |d.%or in| other t|
|00000620| 68 72 65 61 64 73 2c 20 | 69 73 20 6e 6f 74 20 65 |hreads, |is not e|
|00000630| 78 65 63 75 74 65 64 2e | 0a 25 5c 65 6e 64 7b 66 |xecuted.|.%\end{f|
|00000640| 75 6e 63 64 65 73 63 7d | 0a 0a 5c 62 65 67 69 6e |uncdesc}|..\begin|
|00000650| 7b 66 75 6e 63 64 65 73 | 63 7d 7b 61 6c 6c 6f 63 |{funcdes|c}{alloc|
|00000660| 61 74 65 5f 6c 6f 63 6b | 7d 7b 7d 0a 52 65 74 75 |ate_lock|}{}.Retu|
|00000670| 72 6e 20 61 20 6e 65 77 | 20 6c 6f 63 6b 20 6f 62 |rn a new| lock ob|
|00000680| 6a 65 63 74 2e 20 20 4d | 65 74 68 6f 64 73 20 6f |ject. M|ethods o|
|00000690| 66 20 6c 6f 63 6b 73 20 | 61 72 65 20 64 65 73 63 |f locks |are desc|
|000006a0| 72 69 62 65 64 20 62 65 | 6c 6f 77 2e 20 20 54 68 |ribed be|low. Th|
|000006b0| 65 0a 6c 6f 63 6b 20 69 | 73 20 69 6e 69 74 69 61 |e.lock i|s initia|
|000006c0| 6c 6c 79 20 75 6e 6c 6f | 63 6b 65 64 2e 0a 5c 65 |lly unlo|cked..\e|
|000006d0| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0a 0a 5c 62 |nd{funcd|esc}..\b|
|000006e0| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 67 |egin{fun|cdesc}{g|
|000006f0| 65 74 5f 69 64 65 6e 74 | 7d 7b 7d 0a 52 65 74 75 |et_ident|}{}.Retu|
|00000700| 72 6e 20 74 68 65 20 60 | 74 68 72 65 61 64 20 69 |rn the `|thread i|
|00000710| 64 65 6e 74 69 66 69 65 | 72 27 20 6f 66 20 74 68 |dentifie|r' of th|
|00000720| 65 20 63 75 72 72 65 6e | 74 20 74 68 72 65 61 64 |e curren|t thread|
|00000730| 2e 20 20 54 68 69 73 20 | 69 73 20 61 0a 6e 6f 6e |. This |is a.non|
|00000740| 7a 65 72 6f 20 69 6e 74 | 65 67 65 72 2e 20 20 49 |zero int|eger. I|
|00000750| 74 73 20 76 61 6c 75 65 | 20 68 61 73 20 6e 6f 20 |ts value| has no |
|00000760| 64 69 72 65 63 74 20 6d | 65 61 6e 69 6e 67 3b 20 |direct m|eaning; |
|00000770| 69 74 20 69 73 20 69 6e | 74 65 6e 64 65 64 20 61 |it is in|tended a|
|00000780| 73 20 61 0a 6d 61 67 69 | 63 20 63 6f 6f 6b 69 65 |s a.magi|c cookie|
|00000790| 20 74 6f 20 62 65 20 75 | 73 65 64 20 65 2e 67 2e | to be u|sed e.g.|
|000007a0| 20 74 6f 20 69 6e 64 65 | 78 20 61 20 64 69 63 74 | to inde|x a dict|
|000007b0| 69 6f 6e 61 72 79 20 6f | 66 20 74 68 72 65 61 64 |ionary o|f thread|
|000007c0| 2d 73 70 65 63 69 66 69 | 63 0a 64 61 74 61 2e 20 |-specifi|c.data. |
|000007d0| 20 54 68 72 65 61 64 20 | 69 64 65 6e 74 69 66 69 | Thread |identifi|
|000007e0| 65 72 73 20 6d 61 79 20 | 62 65 20 72 65 63 79 63 |ers may |be recyc|
|000007f0| 6c 65 64 20 77 68 65 6e | 20 61 20 74 68 72 65 61 |led when| a threa|
|00000800| 64 20 65 78 69 74 73 20 | 61 6e 64 0a 61 6e 6f 74 |d exits |and.anot|
|00000810| 68 65 72 20 74 68 72 65 | 61 64 20 69 73 20 63 72 |her thre|ad is cr|
|00000820| 65 61 74 65 64 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |eated..\|end{func|
|00000830| 64 65 73 63 7d 0a 0a 4c | 6f 63 6b 20 6f 62 6a 65 |desc}..L|ock obje|
|00000840| 63 74 73 20 68 61 76 65 | 20 74 68 65 20 66 6f 6c |cts have| the fol|
|00000850| 6c 6f 77 69 6e 67 20 6d | 65 74 68 6f 64 73 3a 0a |lowing m|ethods:.|
|00000860| 0a 5c 72 65 6e 65 77 63 | 6f 6d 6d 61 6e 64 7b 5c |.\renewc|ommand{\|
|00000870| 69 6e 64 65 78 73 75 62 | 69 74 65 6d 7d 7b 28 6c |indexsub|item}{(l|
|00000880| 6f 63 6b 20 6d 65 74 68 | 6f 64 29 7d 0a 5c 62 65 |ock meth|od)}.\be|
|00000890| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 61 63 |gin{func|desc}{ac|
|000008a0| 71 75 69 72 65 7d 7b 5c | 6f 70 74 69 6f 6e 61 6c |quire}{\|optional|
|000008b0| 7b 77 61 69 74 66 6c 61 | 67 7d 7d 0a 57 69 74 68 |{waitfla|g}}.With|
|000008c0| 6f 75 74 20 74 68 65 20 | 6f 70 74 69 6f 6e 61 6c |out the |optional|
|000008d0| 20 61 72 67 75 6d 65 6e | 74 2c 20 74 68 69 73 20 | argumen|t, this |
|000008e0| 6d 65 74 68 6f 64 20 61 | 63 71 75 69 72 65 73 20 |method a|cquires |
|000008f0| 74 68 65 20 6c 6f 63 6b | 0a 75 6e 63 6f 6e 64 69 |the lock|.uncondi|
|00000900| 74 69 6f 6e 61 6c 6c 79 | 2c 20 69 66 20 6e 65 63 |tionally|, if nec|
|00000910| 65 73 73 61 72 79 20 77 | 61 69 74 69 6e 67 20 75 |essary w|aiting u|
|00000920| 6e 74 69 6c 20 69 74 20 | 69 73 20 72 65 6c 65 61 |ntil it |is relea|
|00000930| 73 65 64 20 62 79 20 61 | 6e 6f 74 68 65 72 0a 74 |sed by a|nother.t|
|00000940| 68 72 65 61 64 20 28 6f | 6e 6c 79 20 6f 6e 65 20 |hread (o|nly one |
|00000950| 74 68 72 65 61 64 20 61 | 74 20 61 20 74 69 6d 65 |thread a|t a time|
|00000960| 20 63 61 6e 20 61 63 71 | 75 69 72 65 20 61 20 6c | can acq|uire a l|
|00000970| 6f 63 6b 20 2d 2d 2d 20 | 74 68 61 74 27 73 20 74 |ock --- |that's t|
|00000980| 68 65 69 72 0a 72 65 61 | 73 6f 6e 20 66 6f 72 20 |heir.rea|son for |
|00000990| 65 78 69 73 74 65 6e 63 | 65 29 2c 20 61 6e 64 20 |existenc|e), and |
|000009a0| 72 65 74 75 72 6e 73 20 | 5c 63 6f 64 65 7b 4e 6f |returns |\code{No|
|000009b0| 6e 65 7d 2e 20 20 49 66 | 20 74 68 65 20 69 6e 74 |ne}. If| the int|
|000009c0| 65 67 65 72 0a 5c 76 61 | 72 7b 77 61 69 74 66 6c |eger.\va|r{waitfl|
|000009d0| 61 67 7d 20 61 72 67 75 | 6d 65 6e 74 20 69 73 20 |ag} argu|ment is |
|000009e0| 70 72 65 73 65 6e 74 2c | 20 74 68 65 20 61 63 74 |present,| the act|
|000009f0| 69 6f 6e 20 64 65 70 65 | 6e 64 73 20 6f 6e 20 69 |ion depe|nds on i|
|00000a00| 74 73 20 76 61 6c 75 65 | 3a 5c 0a 69 66 20 69 74 |ts value|:\.if it|
|00000a10| 20 69 73 20 7a 65 72 6f | 2c 20 74 68 65 20 6c 6f | is zero|, the lo|
|00000a20| 63 6b 20 69 73 20 6f 6e | 6c 79 20 61 63 71 75 69 |ck is on|ly acqui|
|00000a30| 72 65 64 20 69 66 20 69 | 74 20 63 61 6e 20 62 65 |red if i|t can be|
|00000a40| 20 61 63 71 75 69 72 65 | 64 0a 69 6d 6d 65 64 69 | acquire|d.immedi|
|00000a50| 61 74 65 6c 79 20 77 69 | 74 68 6f 75 74 20 77 61 |ately wi|thout wa|
|00000a60| 69 74 69 6e 67 2c 20 77 | 68 69 6c 65 20 69 66 20 |iting, w|hile if |
|00000a70| 69 74 20 69 73 20 6e 6f | 6e 7a 65 72 6f 2c 20 74 |it is no|nzero, t|
|00000a80| 68 65 20 6c 6f 63 6b 20 | 69 73 0a 61 63 71 75 69 |he lock |is.acqui|
|00000a90| 72 65 64 20 75 6e 63 6f | 6e 64 69 74 69 6f 6e 61 |red unco|nditiona|
|00000aa0| 6c 6c 79 20 61 73 20 62 | 65 66 6f 72 65 2e 20 20 |lly as b|efore. |
|00000ab0| 49 66 20 61 6e 20 61 72 | 67 75 6d 65 6e 74 20 69 |If an ar|gument i|
|00000ac0| 73 20 70 72 65 73 65 6e | 74 2c 20 74 68 65 0a 72 |s presen|t, the.r|
|00000ad0| 65 74 75 72 6e 20 76 61 | 6c 75 65 20 69 73 20 31 |eturn va|lue is 1|
|00000ae0| 20 69 66 20 74 68 65 20 | 6c 6f 63 6b 20 69 73 20 | if the |lock is |
|00000af0| 61 63 71 75 69 72 65 64 | 20 73 75 63 63 65 73 73 |acquired| success|
|00000b00| 66 75 6c 6c 79 2c 20 30 | 20 69 66 20 6e 6f 74 2e |fully, 0| if not.|
|00000b10| 0a 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0a |.\end{fu|ncdesc}.|
|00000b20| 0a 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00000b30| 7d 7b 72 65 6c 65 61 73 | 65 7d 7b 7d 0a 52 65 6c |}{releas|e}{}.Rel|
|00000b40| 65 61 73 65 73 20 74 68 | 65 20 6c 6f 63 6b 2e 20 |eases th|e lock. |
|00000b50| 20 54 68 65 20 6c 6f 63 | 6b 20 6d 75 73 74 20 68 | The loc|k must h|
|00000b60| 61 76 65 20 62 65 65 6e | 20 61 63 71 75 69 72 65 |ave been| acquire|
|00000b70| 64 20 65 61 72 6c 69 65 | 72 2c 20 62 75 74 20 6e |d earlie|r, but n|
|00000b80| 6f 74 0a 6e 65 63 65 73 | 73 61 72 69 6c 79 20 62 |ot.neces|sarily b|
|00000b90| 79 20 74 68 65 20 73 61 | 6d 65 20 74 68 72 65 61 |y the sa|me threa|
|00000ba0| 64 2e 0a 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |d..\end{|funcdesc|
|00000bb0| 7d 0a 0a 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|00000bc0| 73 63 7d 7b 6c 6f 63 6b | 65 64 7d 7b 7d 0a 52 65 |sc}{lock|ed}{}.Re|
|00000bd0| 74 75 72 6e 20 74 68 65 | 20 73 74 61 74 75 73 20 |turn the| status |
|00000be0| 6f 66 20 74 68 65 20 6c | 6f 63 6b 3a 5c 20 31 20 |of the l|ock:\ 1 |
|00000bf0| 69 66 20 69 74 20 68 61 | 73 20 62 65 65 6e 20 61 |if it ha|s been a|
|00000c00| 63 71 75 69 72 65 64 20 | 62 79 20 73 6f 6d 65 0a |cquired |by some.|
|00000c10| 74 68 72 65 61 64 2c 20 | 30 20 69 66 20 6e 6f 74 |thread, |0 if not|
|00000c20| 2e 0a 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|00000c30| 0a 0a 7b 5c 62 66 20 43 | 61 76 65 61 74 73 3a 7d |..{\bf C|aveats:}|
|00000c40| 0a 0a 5c 62 65 67 69 6e | 7b 69 74 65 6d 69 7a 65 |..\begin|{itemize|
|00000c50| 7d 0a 5c 69 74 65 6d 0a | 54 68 72 65 61 64 73 20 |}.\item.|Threads |
|00000c60| 69 6e 74 65 72 61 63 74 | 20 73 74 72 61 6e 67 65 |interact| strange|
|00000c70| 6c 79 20 77 69 74 68 20 | 69 6e 74 65 72 72 75 70 |ly with |interrup|
|00000c80| 74 73 3a 20 74 68 65 0a | 5c 63 6f 64 65 7b 4b 65 |ts: the.|\code{Ke|
|00000c90| 79 62 6f 61 72 64 49 6e | 74 65 72 72 75 70 74 7d |yboardIn|terrupt}|
|00000ca0| 20 65 78 63 65 70 74 69 | 6f 6e 20 77 69 6c 6c 20 | excepti|on will |
|00000cb0| 62 65 20 72 65 63 65 69 | 76 65 64 20 62 79 20 61 |be recei|ved by a|
|00000cc0| 6e 20 61 72 62 69 74 72 | 61 72 79 0a 74 68 72 65 |n arbitr|ary.thre|
|00000cd0| 61 64 2e 20 20 28 57 68 | 65 6e 20 74 68 65 20 5c |ad. (Wh|en the \|
|00000ce0| 63 6f 64 65 7b 73 69 67 | 6e 61 6c 7d 20 6d 6f 64 |code{sig|nal} mod|
|00000cf0| 75 6c 65 20 69 73 20 61 | 76 61 69 6c 61 62 6c 65 |ule is a|vailable|
|00000d00| 2c 20 69 6e 74 65 72 72 | 75 70 74 73 0a 61 6c 77 |, interr|upts.alw|
|00000d10| 61 79 73 20 67 6f 20 74 | 6f 20 74 68 65 20 6d 61 |ays go t|o the ma|
|00000d20| 69 6e 20 74 68 72 65 61 | 64 2e 29 0a 0a 5c 69 74 |in threa|d.)..\it|
|00000d30| 65 6d 0a 43 61 6c 6c 69 | 6e 67 20 5c 63 6f 64 65 |em.Calli|ng \code|
|00000d40| 7b 73 79 73 2e 65 78 69 | 74 28 29 7d 20 6f 72 20 |{sys.exi|t()} or |
|00000d50| 72 61 69 73 69 6e 67 20 | 74 68 65 20 5c 63 6f 64 |raising |the \cod|
|00000d60| 65 7b 53 79 73 74 65 6d | 45 78 69 74 7d 20 69 73 |e{System|Exit} is|
|00000d70| 0a 65 71 75 69 76 61 6c | 65 6e 74 20 74 6f 20 63 |.equival|ent to c|
|00000d80| 61 6c 6c 69 6e 67 20 5c | 63 6f 64 65 7b 74 68 72 |alling \|code{thr|
|00000d90| 65 61 64 2e 65 78 69 74 | 5f 74 68 72 65 61 64 28 |ead.exit|_thread(|
|00000da0| 29 7d 2e 0a 0a 5c 69 74 | 65 6d 0a 4e 6f 74 20 61 |)}...\it|em.Not a|
|00000db0| 6c 6c 20 62 75 69 6c 74 | 2d 69 6e 20 66 75 6e 63 |ll built|-in func|
|00000dc0| 74 69 6f 6e 73 20 74 68 | 61 74 20 6d 61 79 20 62 |tions th|at may b|
|00000dd0| 6c 6f 63 6b 20 77 61 69 | 74 69 6e 67 20 66 6f 72 |lock wai|ting for|
|00000de0| 20 49 2f 4f 20 61 6c 6c | 6f 77 20 6f 74 68 65 72 | I/O all|ow other|
|00000df0| 0a 74 68 72 65 61 64 73 | 20 74 6f 20 72 75 6e 2e |.threads| to run.|
|00000e00| 20 20 28 54 68 65 20 6d | 6f 73 74 20 70 6f 70 75 | (The m|ost popu|
|00000e10| 6c 61 72 20 6f 6e 65 73 | 20 28 5c 63 6f 64 65 7b |lar ones| (\code{|
|00000e20| 73 6c 65 65 70 7d 2c 20 | 5c 63 6f 64 65 7b 72 65 |sleep}, |\code{re|
|00000e30| 61 64 7d 2c 0a 5c 63 6f | 64 65 7b 73 65 6c 65 63 |ad},.\co|de{selec|
|00000e40| 74 7d 29 20 77 6f 72 6b | 20 61 73 20 65 78 70 65 |t}) work| as expe|
|00000e50| 63 74 65 64 2e 29 0a 0a | 5c 65 6e 64 7b 69 74 65 |cted.)..|\end{ite|
|00000e60| 6d 69 7a 65 7d 0a | |mize}. | |
+--------+-------------------------+-------------------------+--------+--------+