Access over 20 million homework & study documents

It355 06 multithreading2 2

Content type
User Generated
Showing Page:

Sign up to view the full document!

lock_open Sign Up
Showing Page:

Sign up to view the full document!

lock_open Sign Up
Showing Page:

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 42 pages?
Access Now
Unformatted Attachment Preview
IT355: Internet Technologies & Programming Chapter 03: Multithreading and Multithreaded Servers Yielding and Naming • Thread.yield() is to allow other threads the opportunity to execute (only suggestive) • Naming a thread is very helpful for debugging • When creating a thread, a String name can be given. If not, a new unique name will be assigned Thread t = new Thread( new MyThread(), “aThreadName” ); Manipulating Threads • Thread.activeCount() returns the number of active threads • Thread.enumerate() fills an array with the currently active threads • Thread.currentThread() returns the current thread • Thread dumpStack() prints the current method and all of the calling methods (good for debugging) Thread Priorities • integers between Thread.MIN_PRIORITY and • • • • Thread.MAX_PROIRITY Threads with higher priority tend to be scheduled before those with lower priority. The exact behavior varies between JVMs. The default priority of a new thread is the same as the thread in which was created. Can use setPriority() to set priority Variable Visibility and Sharing • Scoping rules and program structure determine variable sharing. • If two threads can legally reference an object (i.e. visible), both can use it. • Sharing can be convenient for communication between threads. • Sharing must be carefully controlled Otherwise, an execution mat produce unpredictable results. Stack-local Variables • The behavior of ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Super useful! Studypool never disappoints.