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
Threading in java - a pragmatic primer
PDF
Java Threads: Lightweight Processes
PPTX
PPT
Programming - Java-Threads-and-Synchronization.ppt
PPTX
84694646456445645645645665656465464sdd.pptx
PPT
Java Multithreading and Concurrency
PDF
Java Multithreading Interview Questions PDF By ScholarHat
PPTX
java.pptxytbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PDF
JAVA 3.2.pdfhdfkjhdfvbjdbjfhjdfhdjhfjdfdjfhdjhjd
PPTX
unit-3java.pptx
PDF
Ppl for students unit 4 and 5
PDF
Ppl for students unit 4 and 5
PDF
Java Tutorials - Concurrency
PPTX
Multi-Threading in Java power point presenetation
PPT
web programming-Multithreading concept in Java.ppt
PPTX
THREADALLABOUTCOMOUTERHOWTOYHISDOTH.pptx
DOC
Concurrency Learning From Jdk Source
PPTX
Java Concurrency and Asynchronous
PPTX
Multithreading in Java Object Oriented Programming language
PPT
Java multi threading
Threading in java - a pragmatic primer
Java Threads: Lightweight Processes
Programming - Java-Threads-and-Synchronization.ppt
84694646456445645645645665656465464sdd.pptx
Java Multithreading and Concurrency
Java Multithreading Interview Questions PDF By ScholarHat
java.pptxytbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
JAVA 3.2.pdfhdfkjhdfvbjdbjfhjdfhdjhfjdfdjfhdjhjd
unit-3java.pptx
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
Java Tutorials - Concurrency
Multi-Threading in Java power point presenetation
web programming-Multithreading concept in Java.ppt
THREADALLABOUTCOMOUTERHOWTOYHISDOTH.pptx
Concurrency Learning From Jdk Source
Java Concurrency and Asynchronous
Multithreading in Java Object Oriented Programming language
Java multi threading
Ad

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Cloud computing and distributed systems.
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PPT
Teaching material agriculture food technology
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation theory and applications.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Cloud computing and distributed systems.
Machine learning based COVID-19 study performance prediction
Advanced methodologies resolving dimensionality complications for autism neur...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Dropbox Q2 2025 Financial Results & Investor Presentation
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
Teaching material agriculture food technology
Assigned Numbers - 2025 - Bluetooth® Document
gpt5_lecture_notes_comprehensive_20250812015547.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Unlocking AI with Model Context Protocol (MCP)
Encapsulation theory and applications.pdf

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