Thread join() method


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Thread join() method

This article describes the join() method which available in java.util.Thread. There are also some practical examples displayed.

More...
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #412
Difficulty: Medium
AT&T 3B computer systems included the 3B2, 3B5, 3B15, 3B20S, and 3B4000. These computers were named after the successful 3B20D. The 3B20S (simplex) ran using the UNIX operating system and was developed at Bell Labs and produced by WECo in 1982 for the general purpose internal Bell System use, and later the mini-computer market.
True or False?

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join, merge, fill NULL the void columns of multiples files like sql "LEFT JOIN" by using awk

Hello, This post is already here but want to do this with another way Merge multiples files with multiples duplicates keys by filling "NULL" the void columns for anothers joinning files file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: 1|123|jojo 1|NULL|bibi... (2 Replies)
Discussion started by: yjacknewton
2 Replies

2. UNIX for Dummies Questions & Answers

How to use the the join command to join multiple files by a common column

Hi, I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column). I want to write a script to join the files by the first common column so that in the... (5 Replies)
Discussion started by: evelibertine
5 Replies

3. Solaris

svc:/network/physical:default: Method "/lib/svc/method/net-physical" failed with exit status 96. [ n

After a memory upgrade all network interfaces are misconfigued. How do i resolve this issue. Below are some out puts.thanks. ifconfig: plumb: SIOCLIFADDIF: eg000g0:2: no such interface # ifconfig eg1000g0:2 plumb ifconfig: plumb: SIOCLIFADDIF: eg1000g0:2: no such interface # ifconfig... (2 Replies)
Discussion started by: andersonedouard
2 Replies

4. UNIX for Dummies Questions & Answers

Join 2 files with multiple columns: awk/grep/join?

Hello, My apologies if this has been posted elsewhere, I have had a look at several threads but I am still confused how to use these functions. I have two files, each with 5 columns: File A: (tab-delimited) PDB CHAIN Start End Fragment 1avq A 171 176 awyfan 1avq A 172 177 wyfany 1c7k A 2 7... (3 Replies)
Discussion started by: InfoSeeker
3 Replies

5. Programming

sql,multiple join,outer join issue

example sql: select a.a1,b.b1,c.c1,d.d1,e.e1 from a left outer join b on a.x=b.x left outer join c on b.y=c.y left outer join d on d.z=a.z inner join a.t=e.t I know how single outer or inner join works in sql. But I don't really understand when there are multiple of them. can... (0 Replies)
Discussion started by: robbiezr
0 Replies

6. Shell Programming and Scripting

join (pls help on join command)

Hi, I am a new learner of join command. Some result really make me confused. Please kindly help me. input: file1: LEO oracle engineer 210375 P.Jones Office Runner ID897 L.Clip Personl Chief ID982 S.Round UNIX admin ID6 file2: Dept2C ID897 6 years Dept5Z ID982 1 year Dept3S ID6 2... (1 Reply)
Discussion started by: summer_cherry
1 Replies
Thread(3pm)						 Perl Programmers Reference Guide					       Thread(3pm)

NAME
Thread - Manipulate threads in Perl (for old code only) DEPRECATED
The "Thread" module served as the frontend to the old-style thread model, called 5005threads, that was introduced in release 5.005. That model was deprecated, and has been removed in version 5.10. For old code and interim backwards compatibility, the "Thread" module has been reworked to function as a frontend for the new interpreter threads (ithreads) model. However, some previous functionality is not available. Further, the data sharing models between the two thread models are completely different, and anything to do with data sharing has to be thought differently. With ithreads, you must explicitly "share()" variables between the threads. You are strongly encouraged to migrate any existing threaded code to the new model (i.e., use the "threads" and "threads::shared" modules) as soon as possible. HISTORY
In Perl 5.005, the thread model was that all data is implicitly shared, and shared access to data has to be explicitly synchronized. This model is called 5005threads. In Perl 5.6, a new model was introduced in which all is was thread local and shared access to data has to be explicitly declared. This model is called ithreads, for "interpreter threads". In Perl 5.6, the ithreads model was not available as a public API; only as an internal API that was available for extension writers, and to implement fork() emulation on Win32 platforms. In Perl 5.8, the ithreads model became available through the "threads" module, and the 5005threads model was deprecated. In Perl 5.10, the 5005threads model was removed from the Perl interpreter. SYNOPSIS
use Thread qw(:DEFAULT async yield); my $t = Thread->new(&start_sub, @start_args); $result = $t->join; $t->detach; if ($t->done) { $t->join; } if($t->equal($another_thread)) { # ... } yield(); my $tid = Thread->self->tid; lock($scalar); lock(@array); lock(%hash); my @list = Thread->list; DESCRIPTION
The "Thread" module provides multithreading support for Perl. FUNCTIONS
$thread = Thread->new(&start_sub) $thread = Thread->new(&start_sub, LIST) "new" starts a new thread of execution in the referenced subroutine. The optional list is passed as parameters to the subroutine. Execution continues in both the subroutine and the code after the "new" call. "Thread->new" returns a thread object representing the newly created thread. lock VARIABLE "lock" places a lock on a variable until the lock goes out of scope. If the variable is locked by another thread, the "lock" call will block until it's available. "lock" is recursive, so multiple calls to "lock" are safe--the variable will remain locked until the outermost lock on the variable goes out of scope. Locks on variables only affect "lock" calls--they do not affect normal access to a variable. (Locks on subs are different, and covered in a bit.) If you really, really want locks to block access, then go ahead and tie them to something and manage this yourself. This is done on purpose. While managing access to variables is a good thing, Perl doesn't force you out of its living room... If a container object, such as a hash or array, is locked, all the elements of that container are not locked. For example, if a thread does a "lock @a", any other thread doing a "lock($a[12])" won't block. Finally, "lock" will traverse up references exactly one level. "lock($a)" is equivalent to "lock($a)", while "lock(\$a)" is not. async BLOCK; "async" creates a thread to execute the block immediately following it. This block is treated as an anonymous sub, and so must have a semi-colon after the closing brace. Like "Thread->new", "async" returns a thread object. Thread->self The "Thread->self" function returns a thread object that represents the thread making the "Thread->self" call. Thread->list Returns a list of all non-joined, non-detached Thread objects. cond_wait VARIABLE The "cond_wait" function takes a locked variable as a parameter, unlocks the variable, and blocks until another thread does a "cond_signal" or "cond_broadcast" for that same locked variable. The variable that "cond_wait" blocked on is relocked after the "cond_wait" is satisfied. If there are multiple threads "cond_wait"ing on the same variable, all but one will reblock waiting to reaquire the lock on the variable. (So if you're only using "cond_wait" for synchronization, give up the lock as soon as possible.) cond_signal VARIABLE The "cond_signal" function takes a locked variable as a parameter and unblocks one thread that's "cond_wait"ing on that variable. If more than one thread is blocked in a "cond_wait" on that variable, only one (and which one is indeterminate) will be unblocked. If there are no threads blocked in a "cond_wait" on the variable, the signal is discarded. cond_broadcast VARIABLE The "cond_broadcast" function works similarly to "cond_signal". "cond_broadcast", though, will unblock all the threads that are blocked in a "cond_wait" on the locked variable, rather than only one. yield The "yield" function allows another thread to take control of the CPU. The exact results are implementation-dependent. METHODS
join "join" waits for a thread to end and returns any values the thread exited with. "join" will block until the thread has ended, though it won't block if the thread has already terminated. If the thread being "join"ed "die"d, the error it died with will be returned at this time. If you don't want the thread performing the "join" to die as well, you should either wrap the "join" in an "eval" or use the "eval" thread method instead of "join". detach "detach" tells a thread that it is never going to be joined i.e. that all traces of its existence can be removed once it stops running. Errors in detached threads will not be visible anywhere - if you want to catch them, you should use $SIG{__DIE__} or something like that. equal "equal" tests whether two thread objects represent the same thread and returns true if they do. tid The "tid" method returns the tid of a thread. The tid is a monotonically increasing integer assigned when a thread is created. The main thread of a program will have a tid of zero, while subsequent threads will have tids assigned starting with one. done The "done" method returns true if the thread you're checking has finished, and false otherwise. DEFUNCT
The following were implemented with 5005threads, but are no longer available with ithreads. lock(&sub) With 5005threads, you could also "lock" a sub such that any calls to that sub from another thread would block until the lock was released. Also, subroutines could be declared with the ":locked" attribute which would serialize access to the subroutine, but allowed different threads non-simultaneous access. eval The "eval" method wrapped an "eval" around a "join", and so waited for a thread to exit, passing along any values the thread might have returned and placing any errors into $@. flags The "flags" method returned the flags for the thread - an integer value corresponding to the internal flags for the thread. SEE ALSO
threads, threads::shared, Thread::Queue, Thread::Semaphore perl v5.12.1 2010-04-26 Thread(3pm)

Featured Tech Videos