SlideShare a Scribd company logo
Java 엿새째
TmaxSoft R&D Center
1
113년	 10월	 22일	 화
자바 교육 계획
1일 : Language, String,
ClassLoader, Proxy
2일 : GC, Collections
3일 : Thread, Java Memory
Model
4일 : AQS, ForkJoin,
Concurrent Utils
5일 : IO, Generics, Annotation,
RMI
6일 : Unsafe, Lambda (Java 8)
2
내겐 바스켓만 보여 (Flow 상태)
213년	 10월	 22일	 화
오늘 내용
sun.misc.Unsafe
Lambda (Java 8)
3
313년	 10월	 22일	 화
sun.misc.Unsafe
4
413년	 10월	 22일	 화
sun.misc.Unsafe
5
A collection of methods for performing low-level, unsafe operations
park, unpark
direct memory manipulation
provide wrappers for malloc, realloc, free, memset, memcpy
(not Java Heap)
direct object memory manipulation
CAS operations : compareAndSwap
defineClass, defineAnonymousClass
513년	 10월	 22일	 화
Java is not safe with Unsafe
6
can easily corrupt memory
fast serialization
super array (non-Java heap)
allocateMemory(long size)
can cause JVM crash
613년	 10월	 22일	 화
Lambda
7
The	
  issue	
  being	
  debated	
  is	
  not	
  whether	
  closures	
  are	
  a	
  
good	
  idea	
  -­‐	
  because	
  they	
  clearly	
  are	
  -­‐	
  but	
  whether	
  
the	
  benefits	
  of	
  retrofi7ng	
  the	
  Java	
  language	
  with	
  
closures	
  are	
  worth	
  the	
  costs.
-­‐	
  Brian	
  Goetz
713년	 10월	 22일	 화
Functional Programming
8
lambda
anonymous function with a single argument
closure
a block of code that may contain free (unbound)
variables
currying
handling multiple argument function with lambda
function
813년	 10월	 22일	 화
Java 8 Lambda Expression
SAM (single abstract method) of an interface
Java lambda expression
a list of formal parameters and a body—an expression
or block—expressed in terms of those parameters
e.g,
s -> s.toUpperCase()
(int a, int b) -> a + b
9
913년	 10월	 22일	 화
Method Reference expression
method reference : refer to a method without invoking it
System::getProperty
"abc"::length
constructor reference : refer to a constructor without creating
a new instance of the named class or array type
ArrayList::new
int[]::new
e.g, Arrays.sort(myIntegerArray, Integer::compare)
10
1013년	 10월	 22일	 화
Java 8 Closure
For both lambda bodies and inner classes, local
variables in the enclosing context can only be
referenced if they are final or effectively final.
A variable is effectively final if it is never assigned to
after its initialization.
11
1113년	 10월	 22일	 화
Java 8 Currying
Currying :A technique of transforming a multi-argument
function in such a way that it can be called as a chain
of functions, each with a single argument.
12
1213년	 10월	 22일	 화
New Object-oriented feature
mixin
a class which contains a combination of methods
from other classes.
can also be viewed as an interface with implemented
methods.
Mixins encourage code reuse and avoid well-known
pathologies associated with multiple inheritance.
13
1313년	 10월	 22일	 화
Java 8 Default Method
Java’s language addition of mixin-like thing
provides a default implementation for any class that
implements the interface without overriding the
method.
allows new functionality to be added to existing (and
perhaps already widely-distributed) interfaces.
More generally, it provides a mechanism for multiple
inheritance of behavior.
14
1413년	 10월	 22일	 화
Java 8 Changes to Interface
Now, interface method can be default, static and
abstract
all the non-default, non-static methods in the
interface are abstract as before
Default methods of super-interface can be accessed
<InterfaceName>.super.<methodName>()
15
1513년	 10월	 22일	 화
Java 8 Project Lambda
Language Changes
Still, No Function Type
Functional Interface
Default Method
Streams
invokeDynamic
java.util.Spliterator
16
1613년	 10월	 22일	 화
Java Lambda ABC
@interface java.lang.FunctionalInterface
Just a hint for compiler (compile error if does not have
SAM)
any interface which has SAM is functional interface
package java.util.function
lambda function does not create additional classes unlike
anonymous inner classes
it creates a private static lambda method
17
1713년	 10월	 22일	 화
Streams
handle aggregate operations DECLARATIVELY
stream pipeline
1 source : collection, array, generator ftn, IO, ...
0 or more intermediate operations : filter, map, ...
1 terminal operation : forEach, reduce, sum, ...
18
1813년	 10월	 22일	 화
Stages of Streams
txns.stream()
.filter(txn -> txn.getBuyer().getAge() >= 65)
.map(txn -> txn.getSeller())
.distinct()
.sort(comparing(seller -> seller.getName()))
.forEach(seller ->
System.out.println(seller.getName());
19
source
intermediate
intermediate
intermediate
intermediate
terminal
intermediate ops just setup pipeline
and returns new stream
1913년	 10월	 22일	 화
Parallel Streams
A stream pipeline can be created with an orientation of either
serial or parallel
Parallelism may be faster but introduces non-determinism
Internally uses fork-join framework
Collection c = ...;
List r1 = c.stream().map(...).collect(toList());
List r2 = c.parallelStream().map(...).collect(toList());
20
2013년	 10월	 22일	 화
Parallel Streams
21
2113년	 10월	 22일	 화
MethodHandle
java.lang.invoke 패키지
can store references to methods in the constant pool, load
with LDC (load constant)
can obtain a method handle for any method (or field access)
But
MethodHandle invocation performance is not good
Lambda is language level method, MethodHandle is VM
level method
22
2213년	 10월	 22일	 화
Lambda Invocation
desugar implementation method
private static boolean lambda$1(int minAge, Person p) { ... }
lambda metafactory에 MethodHandle argument로 전달
invokeDynamic 호출
Predicate $p = invokedynamic[bootstrap=LambdaMetaFactory, ... ]
moving more work from static compiler to runtime
performance
linkage, capture 비용은 inner class보다 싸지만 invoke 비용은 비싸다!
23
2313년	 10월	 22일	 화
invokeDynamic
invokeStatic
System.currentTimeMillis(), Math.log(1.0)
invokeVirtual
"hello".toUpperCase(), System.out.println()
invokeInterface
myList.add("happy happy"), myRunnable.run()
invokeSpecial (constructor or super call)
new ArrayList(), super.equals(other)
성능 비교
invokeStatic (2.7배) >> invokeDynamic (12.6배) >> reflection
24
2413년	 10월	 22일	 화
다음 시간 예정
JEUS Web Engine
25
여러분의 전성시대는 언제였나요?
2513년	 10월	 22일	 화
Ad

More Related Content

What's hot (20)

Kubernetes #6 advanced scheduling
Kubernetes #6   advanced schedulingKubernetes #6   advanced scheduling
Kubernetes #6 advanced scheduling
Terry Cho
 
Kubernetes #2 monitoring
Kubernetes #2   monitoring Kubernetes #2   monitoring
Kubernetes #2 monitoring
Terry Cho
 
ARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMS
ARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMSARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMS
ARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMS
Arun prasath
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
Shiao-An Yuan
 
Apache Mesos
Apache MesosApache Mesos
Apache Mesos
Puneet soni
 
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
Open Source Consulting
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
Joe Stein
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013
OpenNebula Project
 
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Uri Cohen
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
Saurav Haloi
 
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Joe Stein
 
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
OpenStack Korea Community
 
[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리
NAVER D2
 
OSv at Cassandra Summit
OSv at Cassandra SummitOSv at Cassandra Summit
OSv at Cassandra Summit
Don Marti
 
Building and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and MarathonBuilding and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and Marathon
Julia Mateo
 
Deploying Docker Containers at Scale with Mesos and Marathon
Deploying Docker Containers at Scale with Mesos and MarathonDeploying Docker Containers at Scale with Mesos and Marathon
Deploying Docker Containers at Scale with Mesos and Marathon
Discover Pinterest
 
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
StreamNative
 
Docker volume-isolator-in-mesos
Docker volume-isolator-in-mesosDocker volume-isolator-in-mesos
Docker volume-isolator-in-mesos
Guangya Liu
 
On MongoDB backup
On MongoDB backupOn MongoDB backup
On MongoDB backup
William Yeh
 
Kubernetes #6 advanced scheduling
Kubernetes #6   advanced schedulingKubernetes #6   advanced scheduling
Kubernetes #6 advanced scheduling
Terry Cho
 
Kubernetes #2 monitoring
Kubernetes #2   monitoring Kubernetes #2   monitoring
Kubernetes #2 monitoring
Terry Cho
 
ARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMS
ARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMSARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMS
ARCHITECTING TENANT BASED QOS IN MULTI-TENANT CLOUD PLATFORMS
Arun prasath
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
Shiao-An Yuan
 
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
Open Source Consulting
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
Joe Stein
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013
OpenNebula Project
 
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Uri Cohen
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
Saurav Haloi
 
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Joe Stein
 
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
OpenStack Korea Community
 
[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리
NAVER D2
 
OSv at Cassandra Summit
OSv at Cassandra SummitOSv at Cassandra Summit
OSv at Cassandra Summit
Don Marti
 
Building and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and MarathonBuilding and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and Marathon
Julia Mateo
 
Deploying Docker Containers at Scale with Mesos and Marathon
Deploying Docker Containers at Scale with Mesos and MarathonDeploying Docker Containers at Scale with Mesos and Marathon
Deploying Docker Containers at Scale with Mesos and Marathon
Discover Pinterest
 
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
StreamNative
 
Docker volume-isolator-in-mesos
Docker volume-isolator-in-mesosDocker volume-isolator-in-mesos
Docker volume-isolator-in-mesos
Guangya Liu
 
On MongoDB backup
On MongoDB backupOn MongoDB backup
On MongoDB backup
William Yeh
 

Similar to Java 8 고급 (6/6) (20)

Java mcq
Java mcqJava mcq
Java mcq
avinash9821
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performance
Roger Xia
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8
Dori Waldman
 
Collections and generic class
Collections and generic classCollections and generic class
Collections and generic class
ifis
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
Arun Vasanth
 
Java 8 고급 (4/6)
Java 8 고급 (4/6)Java 8 고급 (4/6)
Java 8 고급 (4/6)
Kyung Koo Yoon
 
Java Course 4: Exceptions & Collections
Java Course 4: Exceptions & CollectionsJava Course 4: Exceptions & Collections
Java Course 4: Exceptions & Collections
Anton Keks
 
22CS305-UNIT-1.pptx ADVANCE JAVA PROGRAMMING
22CS305-UNIT-1.pptx   ADVANCE JAVA PROGRAMMING22CS305-UNIT-1.pptx   ADVANCE JAVA PROGRAMMING
22CS305-UNIT-1.pptx ADVANCE JAVA PROGRAMMING
logesswarisrinivasan
 
Clojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVMClojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVM
Matthias Nüßler
 
G pars
G parsG pars
G pars
NexThoughts Technologies
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with Scala
Neelkanth Sachdeva
 
Core_Java_Interview.pdf
Core_Java_Interview.pdfCore_Java_Interview.pdf
Core_Java_Interview.pdf
ansariparveen06
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
John Stevenson
 
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
G C Reddy Technologies
 
JAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICESJAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICES
Nikunj Parekh
 
Jist of Java
Jist of JavaJist of Java
Jist of Java
Nikunj Parekh
 
Java 10, Java 11 and beyond
Java 10, Java 11 and beyondJava 10, Java 11 and beyond
Java 10, Java 11 and beyond
Rafael Winterhalter
 
GJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptxGJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptx
Paramjit24
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performance
Roger Xia
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8
Dori Waldman
 
Collections and generic class
Collections and generic classCollections and generic class
Collections and generic class
ifis
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
Arun Vasanth
 
Java Course 4: Exceptions & Collections
Java Course 4: Exceptions & CollectionsJava Course 4: Exceptions & Collections
Java Course 4: Exceptions & Collections
Anton Keks
 
22CS305-UNIT-1.pptx ADVANCE JAVA PROGRAMMING
22CS305-UNIT-1.pptx   ADVANCE JAVA PROGRAMMING22CS305-UNIT-1.pptx   ADVANCE JAVA PROGRAMMING
22CS305-UNIT-1.pptx ADVANCE JAVA PROGRAMMING
logesswarisrinivasan
 
Clojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVMClojure - A practical LISP for the JVM
Clojure - A practical LISP for the JVM
Matthias Nüßler
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with Scala
Neelkanth Sachdeva
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
John Stevenson
 
JAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICESJAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICES
Nikunj Parekh
 
GJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptxGJIMT BCA P4UGCA1932U3L6.pptx
GJIMT BCA P4UGCA1932U3L6.pptx
Paramjit24
 
Ad

More from Kyung Koo Yoon (12)

Kubernetes
Kubernetes Kubernetes
Kubernetes
Kyung Koo Yoon
 
Java 8 고급 (5/6)
Java 8 고급 (5/6)Java 8 고급 (5/6)
Java 8 고급 (5/6)
Kyung Koo Yoon
 
Java 8 고급 (3/6)
Java 8 고급 (3/6)Java 8 고급 (3/6)
Java 8 고급 (3/6)
Kyung Koo Yoon
 
Java 8 고급 (2/6)
Java 8 고급 (2/6)Java 8 고급 (2/6)
Java 8 고급 (2/6)
Kyung Koo Yoon
 
Java 8 고급 (1/6)
Java 8 고급 (1/6)Java 8 고급 (1/6)
Java 8 고급 (1/6)
Kyung Koo Yoon
 
Spring Framework - Inversion of Control Container
Spring Framework - Inversion of Control ContainerSpring Framework - Inversion of Control Container
Spring Framework - Inversion of Control Container
Kyung Koo Yoon
 
Smart software engineer
Smart software engineerSmart software engineer
Smart software engineer
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Lecture on Java Concurrency Day 3 on Feb 11, 2009.Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Lecture on Java Concurrency Day 2 on Feb 4, 2009.Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Lecture on Java Concurrency Day 4 on Feb 18, 2009.Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
Lecture on Java Concurrency Day 1 on Jan 21, 2009.Lecture on Java Concurrency Day 1 on Jan 21, 2009.
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
Kyung Koo Yoon
 
창의와 열정, 소프트웨어 엔지니어
창의와 열정, 소프트웨어 엔지니어창의와 열정, 소프트웨어 엔지니어
창의와 열정, 소프트웨어 엔지니어
Kyung Koo Yoon
 
Spring Framework - Inversion of Control Container
Spring Framework - Inversion of Control ContainerSpring Framework - Inversion of Control Container
Spring Framework - Inversion of Control Container
Kyung Koo Yoon
 
Smart software engineer
Smart software engineerSmart software engineer
Smart software engineer
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Lecture on Java Concurrency Day 3 on Feb 11, 2009.Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Lecture on Java Concurrency Day 3 on Feb 11, 2009.
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Lecture on Java Concurrency Day 2 on Feb 4, 2009.Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Lecture on Java Concurrency Day 4 on Feb 18, 2009.Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Kyung Koo Yoon
 
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
Lecture on Java Concurrency Day 1 on Jan 21, 2009.Lecture on Java Concurrency Day 1 on Jan 21, 2009.
Lecture on Java Concurrency Day 1 on Jan 21, 2009.
Kyung Koo Yoon
 
창의와 열정, 소프트웨어 엔지니어
창의와 열정, 소프트웨어 엔지니어창의와 열정, 소프트웨어 엔지니어
창의와 열정, 소프트웨어 엔지니어
Kyung Koo Yoon
 
Ad

Recently uploaded (20)

Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 

Java 8 고급 (6/6)

  • 1. Java 엿새째 TmaxSoft R&D Center 1 113년 10월 22일 화
  • 2. 자바 교육 계획 1일 : Language, String, ClassLoader, Proxy 2일 : GC, Collections 3일 : Thread, Java Memory Model 4일 : AQS, ForkJoin, Concurrent Utils 5일 : IO, Generics, Annotation, RMI 6일 : Unsafe, Lambda (Java 8) 2 내겐 바스켓만 보여 (Flow 상태) 213년 10월 22일 화
  • 3. 오늘 내용 sun.misc.Unsafe Lambda (Java 8) 3 313년 10월 22일 화
  • 5. sun.misc.Unsafe 5 A collection of methods for performing low-level, unsafe operations park, unpark direct memory manipulation provide wrappers for malloc, realloc, free, memset, memcpy (not Java Heap) direct object memory manipulation CAS operations : compareAndSwap defineClass, defineAnonymousClass 513년 10월 22일 화
  • 6. Java is not safe with Unsafe 6 can easily corrupt memory fast serialization super array (non-Java heap) allocateMemory(long size) can cause JVM crash 613년 10월 22일 화
  • 7. Lambda 7 The  issue  being  debated  is  not  whether  closures  are  a   good  idea  -­‐  because  they  clearly  are  -­‐  but  whether   the  benefits  of  retrofi7ng  the  Java  language  with   closures  are  worth  the  costs. -­‐  Brian  Goetz 713년 10월 22일 화
  • 8. Functional Programming 8 lambda anonymous function with a single argument closure a block of code that may contain free (unbound) variables currying handling multiple argument function with lambda function 813년 10월 22일 화
  • 9. Java 8 Lambda Expression SAM (single abstract method) of an interface Java lambda expression a list of formal parameters and a body—an expression or block—expressed in terms of those parameters e.g, s -> s.toUpperCase() (int a, int b) -> a + b 9 913년 10월 22일 화
  • 10. Method Reference expression method reference : refer to a method without invoking it System::getProperty "abc"::length constructor reference : refer to a constructor without creating a new instance of the named class or array type ArrayList::new int[]::new e.g, Arrays.sort(myIntegerArray, Integer::compare) 10 1013년 10월 22일 화
  • 11. Java 8 Closure For both lambda bodies and inner classes, local variables in the enclosing context can only be referenced if they are final or effectively final. A variable is effectively final if it is never assigned to after its initialization. 11 1113년 10월 22일 화
  • 12. Java 8 Currying Currying :A technique of transforming a multi-argument function in such a way that it can be called as a chain of functions, each with a single argument. 12 1213년 10월 22일 화
  • 13. New Object-oriented feature mixin a class which contains a combination of methods from other classes. can also be viewed as an interface with implemented methods. Mixins encourage code reuse and avoid well-known pathologies associated with multiple inheritance. 13 1313년 10월 22일 화
  • 14. Java 8 Default Method Java’s language addition of mixin-like thing provides a default implementation for any class that implements the interface without overriding the method. allows new functionality to be added to existing (and perhaps already widely-distributed) interfaces. More generally, it provides a mechanism for multiple inheritance of behavior. 14 1413년 10월 22일 화
  • 15. Java 8 Changes to Interface Now, interface method can be default, static and abstract all the non-default, non-static methods in the interface are abstract as before Default methods of super-interface can be accessed <InterfaceName>.super.<methodName>() 15 1513년 10월 22일 화
  • 16. Java 8 Project Lambda Language Changes Still, No Function Type Functional Interface Default Method Streams invokeDynamic java.util.Spliterator 16 1613년 10월 22일 화
  • 17. Java Lambda ABC @interface java.lang.FunctionalInterface Just a hint for compiler (compile error if does not have SAM) any interface which has SAM is functional interface package java.util.function lambda function does not create additional classes unlike anonymous inner classes it creates a private static lambda method 17 1713년 10월 22일 화
  • 18. Streams handle aggregate operations DECLARATIVELY stream pipeline 1 source : collection, array, generator ftn, IO, ... 0 or more intermediate operations : filter, map, ... 1 terminal operation : forEach, reduce, sum, ... 18 1813년 10월 22일 화
  • 19. Stages of Streams txns.stream() .filter(txn -> txn.getBuyer().getAge() >= 65) .map(txn -> txn.getSeller()) .distinct() .sort(comparing(seller -> seller.getName())) .forEach(seller -> System.out.println(seller.getName()); 19 source intermediate intermediate intermediate intermediate terminal intermediate ops just setup pipeline and returns new stream 1913년 10월 22일 화
  • 20. Parallel Streams A stream pipeline can be created with an orientation of either serial or parallel Parallelism may be faster but introduces non-determinism Internally uses fork-join framework Collection c = ...; List r1 = c.stream().map(...).collect(toList()); List r2 = c.parallelStream().map(...).collect(toList()); 20 2013년 10월 22일 화
  • 22. MethodHandle java.lang.invoke 패키지 can store references to methods in the constant pool, load with LDC (load constant) can obtain a method handle for any method (or field access) But MethodHandle invocation performance is not good Lambda is language level method, MethodHandle is VM level method 22 2213년 10월 22일 화
  • 23. Lambda Invocation desugar implementation method private static boolean lambda$1(int minAge, Person p) { ... } lambda metafactory에 MethodHandle argument로 전달 invokeDynamic 호출 Predicate $p = invokedynamic[bootstrap=LambdaMetaFactory, ... ] moving more work from static compiler to runtime performance linkage, capture 비용은 inner class보다 싸지만 invoke 비용은 비싸다! 23 2313년 10월 22일 화
  • 24. invokeDynamic invokeStatic System.currentTimeMillis(), Math.log(1.0) invokeVirtual "hello".toUpperCase(), System.out.println() invokeInterface myList.add("happy happy"), myRunnable.run() invokeSpecial (constructor or super call) new ArrayList(), super.equals(other) 성능 비교 invokeStatic (2.7배) >> invokeDynamic (12.6배) >> reflection 24 2413년 10월 22일 화
  • 25. 다음 시간 예정 JEUS Web Engine 25 여러분의 전성시대는 언제였나요? 2513년 10월 22일 화