Movatterモバイル変換


[0]ホーム

URL:


PPTX, PDF2,258 views

Threading in java - a pragmatic primer

This document discusses concepts related to threads and concurrency in Java. It begins by defining processes and threads, explaining that processes contain threads. It then covers key threading concepts like thread pools, synchronization, and data management between threads. The document provides examples of why threads are used and best practices for writing threaded code in Java. It also discusses common threading issues like deadlocks and race conditions and how to avoid them.

Embed presentation

Downloaded 88 times
SivaramaSundar.D29th Nov 2012
 Concepts When & Why do we need threads Threads in java Concurrency: Thread control & Synchronization Concurrency: Data management between threads Best practices: Threading the right way; Q&A
 Processes A Process has a self-contained execution environment; an application, in general terms – with ownmemory address space; with a main execution thread; which can own O/S resource handles – files,sockets etc. 1..* threads; Each process has one Main thread; System threads – GC, Object finalization, JVM housekeeping Timers and User created threads Threads Execution unit – to execute a sequence of instructions Owns: Stack, Program Counter, Local variables Shares: Memory, Filehandles, Process States ThreadGroups Grouping threads into a logical collection; Not used much. ThreadPools A thread pool is a collection of threads set aside for a specific task; Ex: webserver thread pool; savesthread creation overheads everytime; execute(Runnable command) Used for executing large numbers of asynchronous tasks provide a boundary mechanism to create and managing the resources within the pool Better thread management; Cleaner shutdown of threads; Ability to Add, Remove, Enumerate future tasks; Apt for a scheduler;
 Multitasking – Receive data via a socket & write to file(s) A Server handling multiple concurrent requests to serve data Make the UI more responsive Number crunching; Bulk data processing; Take advantage of multiprocessor systems Simplify program logic when there are multiple independententities Perform blocking I/O without blocking the entire program Ex: A Webserver A real time device monitor to display device parameters A Monitoring application, polling multiple sources & providing liveupdates
 Runnable Interface & Thread Class, Daemon threads Instantiate the “Thread” Class with a “Runnable” implementation(preferred way!) Subclass the “Thread” class & override the “run” method Start – begin execution setDaemon – thread will be terminatedby VM during shutdown;normal threads won’t; sleep Sleeps are not precise; Sleep either in ms or ns The Sleep can be interrupted,by other threads via the thread.interrupt call Yield (rarely used) - Relinquish control ;during long running operations; Interrupt Interrupts the wait state of the thread; invoked by the thread owner; Raises a InterruptedException
 Join Makes the calling thread wait until other thread completes; Typical usage: make sure all the child threads are terminated; Can be interrupted by the thread.interrupt call wait Notify – Wakes up the thread waiting on the given object’smonitor notifyAll – Wakes up all the threads waiting on the givenobject’s monitor Obselete methods suspend resume Stop – use internal flags, join, wait & interrupt mechanismsinstead
 Timers, TimerTask (Daemon) Schedule tasks (Runnable) for future execution in abackground thread. Tasks may be scheduled for one-timeexecution, or for repeated execution at regular intervals Schedule (task, delay) ThreadFactory Help create threads of a given type; subclassed threads ThreadInfo Contains the information about a thread ThreadReference Object ref. with additional access to thread-specificinformation from the target VM. Provides access to internalstack frames, monitor references.
 Why Synchronization Prevent shared data corruption / thread interference / data integrity Code Locks (Monitors)- Synchronized, Volatile Each object in java has a unique monitor.When a synchronized method / block is invoked by the thread,the thread tries to take ownership of the monitor or block until itgets the ownership;The Thread acquires the monitor for the given object(ex:this / method, class object ref.). A monitor is automaticallyreleased when the method / block execution completes. Only one thread at a timecan own an object's monitor. Synchronized Protect Code & Make data changes visible Block level Method level (uses intrinsic lock of the method’s object instance) Volatile – bypass processer cache to use main memory One thread – One Lock – anytime Locks will be released in the event of any uncaught exceptions Lock Interface for better control than “Synchronized” A single Lock can have multiple Conditions ReentrantLock – lock() ; Try... Finally{ unlock(); } ReentrantReadWriteLock - to get a read / write or both locks
 Data Semaphores– Semaphore (Counting Semaphore) acquire(), release() Mechanism to control access to a pool of shared resource, betweenmultiple processes, threads Acts like a gate – for a limited access pool / lift – with a fixedcapacity; some threads have to yield control, for the other threads toaccess the shared data; While Locks are exclusive, semaphores are not Other examples: Fixed no. of meeting rooms – with controlled access Mutexes – Same as a binary semaphore (lock - yes/no), butacross processes Normally mutexes has owners Typical usage – to ensure single instance of an application / process
 ThreadLocal<T> Provide Local variables for the thread (can be accessed only within this thread) Each thread holds an implicit reference to its copy of a thread-local variable as long as the thread is alive When a thread dies; the thread local variables are subject to GC Java.utils.concurrent ThreadPoolExecutor, ScheduledThreadPoolExecutor Java.util.Collections classes with built in support for handling concurrency & access from multiplethreads; uses collection segmentation & hence supports non-blocking – ex: the whole collectionis not locked; ConcurrentHashMap ConcurrentLinkedDeque ConcurrentLinkedQueue ConcurrentSkipListMap ConcurrentSkipListSet Make normal collections thread safe via - java.util.Collections methods;blocking – ex: whole collection is locked; SynchronousQueue SynchronizedCollection SynchronizedSet SynchronizedList SynchronizedMap SynchronizedSortedSet SynchronizedSortedMap
 Deadlock T1 -> W1; T1.DoSomething waits for W2. T2 -> W2; T2.DoSomething waits for W1. Hard to debug – but jConsole, jStack helps (demo withjConsole); Simplify locks / avoid arbitrary synchronization Race Condition A race condition occurs when 2 or more threads access shared data andthey try to change it at the same time; problems occur when one thread does a "check-then-act" and anotherthread does something to the value in between the "check" and the"act“;tip: avoid ‘check & act’situations when using threading;
 White-boarding & Brainstorming Document / Comment all threading code; Be Aware of the synchronized keyword used aspart of the method name – it is easy to miss if that a synchronized method uses anintrinsic lock; synchronized blocks are easier to spot; Thorough Code Reviews Use locks judiciously – lock while writes Wait for spawned threads to complete, or force stop Exception handling – a thread will terminate on an unhandled exceptionMake use of Thread.setDefaultUncaughtExceptionHandler -handler for all threads in the VMorsetUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) - handler for single specificthread Use immutable classes – Ex: String, Integer, BigDecimal, as they make concurrencyhandling simple Know when JVM performs the synchronization for you: Static Initializer, final fields,Creating objects before threads Avoid nested locks; to prevent deadlocks;
 Don't invoke methods on other objects while holding a lock. (Sounds crazy; ) Ensure that when you acquire multiple locks, you always acquire the locks inthe same order in all threads. Keep the synchronized blocks as short as possible; Don’t use blocking code inside a synchronized block – ex: Inputstream.read() Don’t tamper thread priorities; leave it to the JVM & O/S Avoid starvation of resources; Don’t code long running threads; Aids in debugging threading issues: Thread.holdsLock (Object lockObj)- true if lock is held Thread.dumpStack() Inspect using Thread.State / getState() Provide a thread name when creating a thread Logs – with thread id’s; ThreadInfo class Threaddumps - Provide a stack trace of all running threads (tool from jdk) jstack <pid> >> threaddumps.log (alternate) use jConsole to monitor the jvm & analyze stack trace of all live threads Using the “SendSignal.exe” to send a “break” signal to the process to get a thread dump
 Threading explained in simple terms-http://www.tutorialspoint.com/java/java_multithreading.htmhttp://www.tutorialspoint.com/java/java_thread_synchronization.htmhttp://www.tutorialspoint.com/java/java_multithreading.htmhttp://www.tutorialspoint.com/java/java_thread_communication.htmhttp://www.tutorialspoint.com/java/java_thread_deadlock.htm Java Concurrency in Practice – Book – www.Jcip.net Hardcode multi-threading in java -http://conferences.embarcadero.com/article/32141 Analyzing thread dumps-http://www.javacodegeeks.com/2012/03/jvm-how-to-analyze-thread-dump.html
 ThreadApp.java SimpleJavaThread.java Deadlock.java A.java B.java NewThread.java SuspendResume.java Pool.java
Threading in java - a pragmatic primer

Recommended

PPTX
Concurrency in Java
PPTX
Advanced Introduction to Java Multi-Threading - Full (chok)
PDF
Java Course 10: Threads and Concurrency
PPTX
Basics of Java Concurrency
PPT
Java concurrency
PPT
Java multi threading
PPTX
Thread model of java
PPT
Java Multithreading and Concurrency
PPTX
Multi threading
PDF
Multithreading in Java
PPT
Synchronization.37
ODP
Multithreading In Java
 
PDF
[Java concurrency]02.basic thread synchronization
PPT
Inter threadcommunication.38
PDF
Programming with Threads in Java
PDF
[Java concurrency]01.thread management
PDF
Java Concurrency in Practice
PPTX
PPT
Basic of Multithreading in JAva
PPT
Thread
PDF
Java Multithreading Using Executors Framework
PPT
Java New Evolution
PPT
Threads in Java
PDF
Java unit 12
PPTX
Multithreading in java
PPSX
Multithreading in-java
PDF
Java Multithreading
PPTX
Lecture 23-24.pptx
DOC
Jacob Jean resume
DOCX
E SUNDARATHEVAN RESUME

More Related Content

PPTX
Concurrency in Java
PPTX
Advanced Introduction to Java Multi-Threading - Full (chok)
PDF
Java Course 10: Threads and Concurrency
PPTX
Basics of Java Concurrency
PPT
Java concurrency
PPT
Java multi threading
PPTX
Thread model of java
PPT
Java Multithreading and Concurrency
Concurrency in Java
Advanced Introduction to Java Multi-Threading - Full (chok)
Java Course 10: Threads and Concurrency
Basics of Java Concurrency
Java concurrency
Java multi threading
Thread model of java
Java Multithreading and Concurrency

What's hot

PPTX
Multi threading
PDF
Multithreading in Java
PPT
Synchronization.37
ODP
Multithreading In Java
 
PDF
[Java concurrency]02.basic thread synchronization
PPT
Inter threadcommunication.38
PDF
Programming with Threads in Java
PDF
[Java concurrency]01.thread management
PDF
Java Concurrency in Practice
PPTX
PPT
Basic of Multithreading in JAva
PPT
Thread
PDF
Java Multithreading Using Executors Framework
PPT
Java New Evolution
PPT
Threads in Java
PDF
Java unit 12
PPTX
Multithreading in java
PPSX
Multithreading in-java
PDF
Java Multithreading
PPTX
Lecture 23-24.pptx
Multi threading
Multithreading in Java
Synchronization.37
Multithreading In Java
 
[Java concurrency]02.basic thread synchronization
Inter threadcommunication.38
Programming with Threads in Java
[Java concurrency]01.thread management
Java Concurrency in Practice
Basic of Multithreading in JAva
Thread
Java Multithreading Using Executors Framework
Java New Evolution
Threads in Java
Java unit 12
Multithreading in java
Multithreading in-java
Java Multithreading
Lecture 23-24.pptx

Viewers also liked

DOC
Jacob Jean resume
DOCX
E SUNDARATHEVAN RESUME
DOC
sda.wm
DOC
Anirban Das_BE-NIT_MBA-Symbiosis
PDF
Jenin Thomas-CV
PDF
CV__SD_13-12-2014
DOCX
jugal update cv
DOCX
Subbu_WM
DOC
Snehal Mutalik - Resume
PPTX
Software Open Source
PDF
David A Shattles Resume 2015-11
DOC
AmrendraKumarVerma_Resume
DOC
DianaTChua
PDF
Prem sai resume
DOCX
Juilee s kulkarni
PDF
Resume_satish_kumar_reddy
DOC
Resume (1)
TXT
Jacob Jean resume
E SUNDARATHEVAN RESUME
sda.wm
Anirban Das_BE-NIT_MBA-Symbiosis
Jenin Thomas-CV
CV__SD_13-12-2014
jugal update cv
Subbu_WM
Snehal Mutalik - Resume
Software Open Source
David A Shattles Resume 2015-11
AmrendraKumarVerma_Resume
DianaTChua
Prem sai resume
Juilee s kulkarni
Resume_satish_kumar_reddy
Resume (1)

Similar to Threading in java - a pragmatic primer

PPTX
04 threads-pbl-2-slots
 
PPTX
04 threads-pbl-2-slots
 
PDF
Java Threads: Lightweight Processes
PPTX
84694646456445645645645665656465464sdd.pptx
PPT
Programming - Java-Threads-and-Synchronization.ppt
PPTX
Multithreading
PDF
Multithreading Introduction and Lifecyle of thread
PDF
Multi t hreading_14_10
PDF
JAVA 3.2.pdfhdfkjhdfvbjdbjfhjdfhdjhfjdfdjfhdjhjd
PPTX
Multi-threaded Programming in JAVA
PPTX
econtent thread in java.pptx
PPTX
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx
PPTX
Slide 7 Thread-1.pptx
PPTX
MSBTE Computer Engineering JPR java. multi. threading.pptx
PPTX
Multithreading and concurrency in android
PPTX
Multithreading in java
PPTX
Multithreading in java
PPTX
MULTITHREADING PROGRAMMING AND I/O THREAD
PPTX
Multi Threading
PPT
cs4240-multithreading.ppt presentation on multi threading
04 threads-pbl-2-slots
 
04 threads-pbl-2-slots
 
Java Threads: Lightweight Processes
84694646456445645645645665656465464sdd.pptx
Programming - Java-Threads-and-Synchronization.ppt
Multithreading
Multithreading Introduction and Lifecyle of thread
Multi t hreading_14_10
JAVA 3.2.pdfhdfkjhdfvbjdbjfhjdfhdjhfjdfdjfhdjhjd
Multi-threaded Programming in JAVA
econtent thread in java.pptx
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx
Slide 7 Thread-1.pptx
MSBTE Computer Engineering JPR java. multi. threading.pptx
Multithreading and concurrency in android
Multithreading in java
Multithreading in java
MULTITHREADING PROGRAMMING AND I/O THREAD
Multi Threading
cs4240-multithreading.ppt presentation on multi threading

Recently uploaded

PDF
DevFest El Jadida 2025 - Product Thinking
PDF
GPUS and How to Program Them by Manya Bansal
PDF
Digit Expo 2025 - EICC Edinburgh 27th November
PDF
Internet_of_Things_IoT_for_Next_Generation_Smart_Systems_Utilizing.pdf
PDF
Dev Dives: AI that builds with you - UiPath Autopilot for effortless RPA & AP...
PDF
Day 3 - Data and Application Security - 2nd Sight Lab Cloud Security Class
PDF
Six Shifts For 2026 (And The Next Six Years)
PDF
Is It Possible to Have Wi-Fi Without an Internet Provider
PPTX
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
PDF
December Patch Tuesday
 
PDF
Usage Control for Process Discovery through a Trusted Execution Environment
PDF
Day 5 - Red Team + Blue Team in the Cloud - 2nd Sight Lab Cloud Security Class
PDF
Unlocking the Power of Salesforce Architecture: Frameworks for Effective Solu...
PDF
Unser Jahresrückblick – MarvelClient in 2025
PPTX
Chapter 3 Introduction to number system.pptx
PDF
Security Forum Sessions from Houston 2025 Event
PPTX
Conversational Agents – Building Intelligent Assistants [Virtual Hands-on Wor...
PDF
Making Sense of Raster: From Bit Depth to Better Workflows
PPTX
Cybersecurity Best Practices - Step by Step guidelines
PDF
API-First Architecture in Financial Systems
DevFest El Jadida 2025 - Product Thinking
GPUS and How to Program Them by Manya Bansal
Digit Expo 2025 - EICC Edinburgh 27th November
Internet_of_Things_IoT_for_Next_Generation_Smart_Systems_Utilizing.pdf
Dev Dives: AI that builds with you - UiPath Autopilot for effortless RPA & AP...
Day 3 - Data and Application Security - 2nd Sight Lab Cloud Security Class
Six Shifts For 2026 (And The Next Six Years)
Is It Possible to Have Wi-Fi Without an Internet Provider
Coded Agents – with UiPath SDK + LangGraph [Virtual Hands-on Workshop]
December Patch Tuesday
 
Usage Control for Process Discovery through a Trusted Execution Environment
Day 5 - Red Team + Blue Team in the Cloud - 2nd Sight Lab Cloud Security Class
Unlocking the Power of Salesforce Architecture: Frameworks for Effective Solu...
Unser Jahresrückblick – MarvelClient in 2025
Chapter 3 Introduction to number system.pptx
Security Forum Sessions from Houston 2025 Event
Conversational Agents – Building Intelligent Assistants [Virtual Hands-on Wor...
Making Sense of Raster: From Bit Depth to Better Workflows
Cybersecurity Best Practices - Step by Step guidelines
API-First Architecture in Financial Systems

Threading in java - a pragmatic primer

  • 1.
  • 2.
     Concepts When& Why do we need threads Threads in java Concurrency: Thread control & Synchronization Concurrency: Data management between threads Best practices: Threading the right way; Q&A
  • 3.
     Processes AProcess has a self-contained execution environment; an application, in general terms – with ownmemory address space; with a main execution thread; which can own O/S resource handles – files,sockets etc. 1..* threads; Each process has one Main thread; System threads – GC, Object finalization, JVM housekeeping Timers and User created threads Threads Execution unit – to execute a sequence of instructions Owns: Stack, Program Counter, Local variables Shares: Memory, Filehandles, Process States ThreadGroups Grouping threads into a logical collection; Not used much. ThreadPools A thread pool is a collection of threads set aside for a specific task; Ex: webserver thread pool; savesthread creation overheads everytime; execute(Runnable command) Used for executing large numbers of asynchronous tasks provide a boundary mechanism to create and managing the resources within the pool Better thread management; Cleaner shutdown of threads; Ability to Add, Remove, Enumerate future tasks; Apt for a scheduler;
  • 4.
     Multitasking –Receive data via a socket & write to file(s) A Server handling multiple concurrent requests to serve data Make the UI more responsive Number crunching; Bulk data processing; Take advantage of multiprocessor systems Simplify program logic when there are multiple independententities Perform blocking I/O without blocking the entire program Ex: A Webserver A real time device monitor to display device parameters A Monitoring application, polling multiple sources & providing liveupdates
  • 7.
     Runnable Interface& Thread Class, Daemon threads Instantiate the “Thread” Class with a “Runnable” implementation(preferred way!) Subclass the “Thread” class & override the “run” method Start – begin execution setDaemon – thread will be terminatedby VM during shutdown;normal threads won’t; sleep Sleeps are not precise; Sleep either in ms or ns The Sleep can be interrupted,by other threads via the thread.interrupt call Yield (rarely used) - Relinquish control ;during long running operations; Interrupt Interrupts the wait state of the thread; invoked by the thread owner; Raises a InterruptedException
  • 8.
     Join Makesthe calling thread wait until other thread completes; Typical usage: make sure all the child threads are terminated; Can be interrupted by the thread.interrupt call wait Notify – Wakes up the thread waiting on the given object’smonitor notifyAll – Wakes up all the threads waiting on the givenobject’s monitor Obselete methods suspend resume Stop – use internal flags, join, wait & interrupt mechanismsinstead
  • 9.
     Timers, TimerTask(Daemon) Schedule tasks (Runnable) for future execution in abackground thread. Tasks may be scheduled for one-timeexecution, or for repeated execution at regular intervals Schedule (task, delay) ThreadFactory Help create threads of a given type; subclassed threads ThreadInfo Contains the information about a thread ThreadReference Object ref. with additional access to thread-specificinformation from the target VM. Provides access to internalstack frames, monitor references.
  • 10.
     Why SynchronizationPrevent shared data corruption / thread interference / data integrity Code Locks (Monitors)- Synchronized, Volatile Each object in java has a unique monitor.When a synchronized method / block is invoked by the thread,the thread tries to take ownership of the monitor or block until itgets the ownership;The Thread acquires the monitor for the given object(ex:this / method, class object ref.). A monitor is automaticallyreleased when the method / block execution completes. Only one thread at a timecan own an object's monitor. Synchronized Protect Code & Make data changes visible Block level Method level (uses intrinsic lock of the method’s object instance) Volatile – bypass processer cache to use main memory One thread – One Lock – anytime Locks will be released in the event of any uncaught exceptions Lock Interface for better control than “Synchronized” A single Lock can have multiple Conditions ReentrantLock – lock() ; Try... Finally{ unlock(); } ReentrantReadWriteLock - to get a read / write or both locks
  • 12.
     Data Semaphores–Semaphore (Counting Semaphore) acquire(), release() Mechanism to control access to a pool of shared resource, betweenmultiple processes, threads Acts like a gate – for a limited access pool / lift – with a fixedcapacity; some threads have to yield control, for the other threads toaccess the shared data; While Locks are exclusive, semaphores are not Other examples: Fixed no. of meeting rooms – with controlled access Mutexes – Same as a binary semaphore (lock - yes/no), butacross processes Normally mutexes has owners Typical usage – to ensure single instance of an application / process
  • 13.
     ThreadLocal<T> ProvideLocal variables for the thread (can be accessed only within this thread) Each thread holds an implicit reference to its copy of a thread-local variable as long as the thread is alive When a thread dies; the thread local variables are subject to GC Java.utils.concurrent ThreadPoolExecutor, ScheduledThreadPoolExecutor Java.util.Collections classes with built in support for handling concurrency & access from multiplethreads; uses collection segmentation & hence supports non-blocking – ex: the whole collectionis not locked; ConcurrentHashMap ConcurrentLinkedDeque ConcurrentLinkedQueue ConcurrentSkipListMap ConcurrentSkipListSet Make normal collections thread safe via - java.util.Collections methods;blocking – ex: whole collection is locked; SynchronousQueue SynchronizedCollection SynchronizedSet SynchronizedList SynchronizedMap SynchronizedSortedSet SynchronizedSortedMap
  • 14.
     Deadlock T1-> W1; T1.DoSomething waits for W2. T2 -> W2; T2.DoSomething waits for W1. Hard to debug – but jConsole, jStack helps (demo withjConsole); Simplify locks / avoid arbitrary synchronization Race Condition A race condition occurs when 2 or more threads access shared data andthey try to change it at the same time; problems occur when one thread does a "check-then-act" and anotherthread does something to the value in between the "check" and the"act“;tip: avoid ‘check & act’situations when using threading;
  • 15.
     White-boarding &Brainstorming Document / Comment all threading code; Be Aware of the synchronized keyword used aspart of the method name – it is easy to miss if that a synchronized method uses anintrinsic lock; synchronized blocks are easier to spot; Thorough Code Reviews Use locks judiciously – lock while writes Wait for spawned threads to complete, or force stop Exception handling – a thread will terminate on an unhandled exceptionMake use of Thread.setDefaultUncaughtExceptionHandler -handler for all threads in the VMorsetUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) - handler for single specificthread Use immutable classes – Ex: String, Integer, BigDecimal, as they make concurrencyhandling simple Know when JVM performs the synchronization for you: Static Initializer, final fields,Creating objects before threads Avoid nested locks; to prevent deadlocks;
  • 16.
     Don't invokemethods on other objects while holding a lock. (Sounds crazy; ) Ensure that when you acquire multiple locks, you always acquire the locks inthe same order in all threads. Keep the synchronized blocks as short as possible; Don’t use blocking code inside a synchronized block – ex: Inputstream.read() Don’t tamper thread priorities; leave it to the JVM & O/S Avoid starvation of resources; Don’t code long running threads; Aids in debugging threading issues: Thread.holdsLock (Object lockObj)- true if lock is held Thread.dumpStack() Inspect using Thread.State / getState() Provide a thread name when creating a thread Logs – with thread id’s; ThreadInfo class Threaddumps - Provide a stack trace of all running threads (tool from jdk) jstack <pid> >> threaddumps.log (alternate) use jConsole to monitor the jvm & analyze stack trace of all live threads Using the “SendSignal.exe” to send a “break” signal to the process to get a thread dump
  • 17.
     Threading explainedin simple terms-http://www.tutorialspoint.com/java/java_multithreading.htmhttp://www.tutorialspoint.com/java/java_thread_synchronization.htmhttp://www.tutorialspoint.com/java/java_multithreading.htmhttp://www.tutorialspoint.com/java/java_thread_communication.htmhttp://www.tutorialspoint.com/java/java_thread_deadlock.htm Java Concurrency in Practice – Book – www.Jcip.net Hardcode multi-threading in java -http://conferences.embarcadero.com/article/32141 Analyzing thread dumps-http://www.javacodegeeks.com/2012/03/jvm-how-to-analyze-thread-dump.html
  • 18.
     ThreadApp.java SimpleJavaThread.javaDeadlock.java A.java B.java NewThread.java SuspendResume.java Pool.java

Editor's Notes

  • #6 Pub-Sub messagingMultiple devices sending updates to a UIA Logging service / Common logging component in a huge system, which gets log messages from all other subsystems and persists them via a single thread;----------For simple background tasks; simple threads sufficeFor above options, all the synchronizations mechanisms are needed
  • #14 Ex: Apache web-server, with a configurable thread pool, where in threads shall be pre-created and new threads created only when thenumber of requests become higher and cannot be served by the present pool

[8]ページ先頭

©2009-2025 Movatter.jp