SlideShare a Scribd company logo
Advanced Java I
Thread / IO Stream / Reflection
Agenda I
Thread                              IO Stream
  Muti-thread?
                                      What is “stream”
  Lock & PV Operation
  “synchronized” & “volatile”         Input Stream / Output
                                      Stream
  wait() / notify() / notifyAll()
  Thread VS Runnable                  Reader / Writer
  sleep()                             Buffered xxx
  InterruptedException
                                      Decoration Pattern
  java.util.concurrent
Agenda II
 Reflection
   Class Loader
     static Class.forName()
     Class.newInstance()
   Class / Method
   Annotation
   Dynamic Proxy
Thread Basis
Thread? Process?
Muti-Thread
Critical Resources
Lock & PV Operation
Thread in Java
 “synchronized”
   ~ method
   ~ block
   Synchronize WHAT?
 “volatile”
 wait() / notify() / notifyAll()
   “context”
java.lang.Thread / Runnable
 sleep()
   WHO.sleep()?
 InterruptedException
   interrupt() / interrupted() / isInterrupted()
   A “positive” Exception?
      pause / suspend
Thread in Action I
 Producer / Consumer
 Stop Watch
java.util.concurrent
 java.util.concurrent
   BlockingQueue
   BlockingDeque
   Executors
 java.util.concurrent.locks
   java.util.concurrent.locks.ReentrantLock
   java.util.concurrent.locks.ReentrantReadWriteLock
 java.util.concurrent.atomic
Thread in Action II
 Producer / Consumer again
   BlockingQueue
 Lottery
   Lock
Tea Break
IO Stream
What is Stream?
Input Stream / Output Stream
  java.io.XxxInputStream
  java.io.XxxOutputStream
Reader / Writer
Buffered xxx
How To Use Stream?
Decoration Pattern


File Capitalizer
Class Loader
How JVM Loads a Class?
  Delegation
How to Load Our Own Classes?
  Class.forName()
  Class.newInstance()
  ClassLoader.loadClass() / findClass()
  ClassLoader.defineClass()
Reflection
 Why Reflecting?
   Benefits
   Issues
 How to Reflect?
   Class / Method / Constructor / Field
   Annotation
 Dynamic Proxy
   EJB (before 3.0)
Reflection in Action
 XUnit
   Class Loader
   Reflection
   Annotation
 Programming by Contract
   Dynamic Proxy
   Annotation Again
Q&A

More Related Content

PPTX
OSGi Training for Carbon Developers
PPTX
Deep dive into OSGi Lifecycle Layer
PPTX
Java 10, Java 11 and beyond
PPTX
Java memory model
ODP
Java memory model
PPTX
The definitive guide to java agents
PPTX
The Java memory model made easy
PDF
Java object oriented programming - OOPS
OSGi Training for Carbon Developers
Deep dive into OSGi Lifecycle Layer
Java 10, Java 11 and beyond
Java memory model
Java memory model
The definitive guide to java agents
The Java memory model made easy
Java object oriented programming - OOPS

Viewers also liked (6)

PDF
Advanced java programming-contents
PPS
Advance Java
DOCX
Java J2EE Complete Syllabus Checklist
PPT
Java Notes
PPTX
Advance Java Topics (J2EE)
PDF
Core java complete notes - Contact at +91-814-614-5674
Advanced java programming-contents
Advance Java
Java J2EE Complete Syllabus Checklist
Java Notes
Advance Java Topics (J2EE)
Core java complete notes - Contact at +91-814-614-5674
Ad

Similar to Advanced Java I (20)

PPTX
Basics of Java Concurrency
PDF
Java Concurrency Quick Guide
PDF
Ppl for students unit 4 and 5
PDF
Ppl for students unit 4 and 5
PPTX
Exception Handling and MultiThreading in Java Unit-2.pptx
PPT
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
PDF
What`s new in Java 7
PPT
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
PDF
What is java input and output stream?
PDF
What is java input and output stream?
PDF
Jvm fundamentals
PPT
Java basic tutorial by sanjeevini india
PPT
Java basic tutorial by sanjeevini india
PDF
Top 371 java fa qs useful for freshers and experienced
PDF
Java Faqs useful for freshers and experienced
PPTX
Unit No 4 Exception Handling and Multithreading.pptx
PDF
JAVA UNIT-2 ONE SHOT NOTES_64156529_2025_07_12_10__250712_103642.pdf
PDF
JAVA UNIT-2 ONE SHOT NOTES_64156529_2025_07_12_10__250712_103642.pdf
PDF
55j7
PDF
Delta final paper
Basics of Java Concurrency
Java Concurrency Quick Guide
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
Exception Handling and MultiThreading in Java Unit-2.pptx
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
What`s new in Java 7
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
What is java input and output stream?
What is java input and output stream?
Jvm fundamentals
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Top 371 java fa qs useful for freshers and experienced
Java Faqs useful for freshers and experienced
Unit No 4 Exception Handling and Multithreading.pptx
JAVA UNIT-2 ONE SHOT NOTES_64156529_2025_07_12_10__250712_103642.pdf
JAVA UNIT-2 ONE SHOT NOTES_64156529_2025_07_12_10__250712_103642.pdf
55j7
Delta final paper
Ad

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Machine Learning_overview_presentation.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
cuic standard and advanced reporting.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Big Data Technologies - Introduction.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Machine Learning_overview_presentation.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Weekly Chronicles - August'25-Week II
cuic standard and advanced reporting.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A comparative analysis of optical character recognition models for extracting...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Diabetes mellitus diagnosis method based random forest with bat algorithm
Big Data Technologies - Introduction.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
Unlocking AI with Model Context Protocol (MCP)

Advanced Java I

  • 1. Advanced Java I Thread / IO Stream / Reflection
  • 2. Agenda I Thread IO Stream Muti-thread? What is “stream” Lock & PV Operation “synchronized” & “volatile” Input Stream / Output Stream wait() / notify() / notifyAll() Thread VS Runnable Reader / Writer sleep() Buffered xxx InterruptedException Decoration Pattern java.util.concurrent
  • 3. Agenda II Reflection Class Loader static Class.forName() Class.newInstance() Class / Method Annotation Dynamic Proxy
  • 5. Thread in Java “synchronized” ~ method ~ block Synchronize WHAT? “volatile” wait() / notify() / notifyAll() “context”
  • 6. java.lang.Thread / Runnable sleep() WHO.sleep()? InterruptedException interrupt() / interrupted() / isInterrupted() A “positive” Exception? pause / suspend
  • 7. Thread in Action I Producer / Consumer Stop Watch
  • 8. java.util.concurrent java.util.concurrent BlockingQueue BlockingDeque Executors java.util.concurrent.locks java.util.concurrent.locks.ReentrantLock java.util.concurrent.locks.ReentrantReadWriteLock java.util.concurrent.atomic
  • 9. Thread in Action II Producer / Consumer again BlockingQueue Lottery Lock
  • 11. IO Stream What is Stream? Input Stream / Output Stream java.io.XxxInputStream java.io.XxxOutputStream Reader / Writer Buffered xxx
  • 12. How To Use Stream? Decoration Pattern File Capitalizer
  • 13. Class Loader How JVM Loads a Class? Delegation How to Load Our Own Classes? Class.forName() Class.newInstance() ClassLoader.loadClass() / findClass() ClassLoader.defineClass()
  • 14. Reflection Why Reflecting? Benefits Issues How to Reflect? Class / Method / Constructor / Field Annotation Dynamic Proxy EJB (before 3.0)
  • 15. Reflection in Action XUnit Class Loader Reflection Annotation Programming by Contract Dynamic Proxy Annotation Again
  • 16. Q&A

Editor's Notes