Suche senden
Hochladen
Clh spinlock 实现演示
•
Als PPT, PDF herunterladen
•
0 gefällt mir
•
587 views
S
snakebbf
Folgen
Technologie
Business
Melden
Teilen
Melden
Teilen
1 von 13
Jetzt herunterladen
Empfohlen
Thread safety and code syncronization
Thread safety and code syncronization
Srinivas Reddy
Concurrency: Best Practices
Concurrency: Best Practices
IndicThreads
Java Multithreading and Concurrency
Java Multithreading and Concurrency
Rajesh Ananda Kumar
Paas研究介绍
Paas研究介绍
snakebbf
Hadoop监控
Hadoop监控
snakebbf
Hadoop mapreduce 过程简析
Hadoop mapreduce 过程简析
snakebbf
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Empfohlen
Thread safety and code syncronization
Thread safety and code syncronization
Srinivas Reddy
Concurrency: Best Practices
Concurrency: Best Practices
IndicThreads
Java Multithreading and Concurrency
Java Multithreading and Concurrency
Rajesh Ananda Kumar
Paas研究介绍
Paas研究介绍
snakebbf
Hadoop监控
Hadoop监控
snakebbf
Hadoop mapreduce 过程简析
Hadoop mapreduce 过程简析
snakebbf
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
Weitere ähnliche Inhalte
Empfohlen
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
Empfohlen
(20)
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
Clh spinlock 实现演示
1.
ThreadLocal : ThreadLocal myNode = new ThreadLocal() {
protected QNode initialValue() { return new QNode(); } ThreadLocal<T> 能够访问 Thread 的 }; threadLocalMap key 是 threadLocal 对象, value 是具体使用的 <T> 值 public T get() { Thread t = Thread.currentThread(); ThreadLocalMap map = getMap(t); if (map != null) { ThreadLocalMap.Entry e = map.getEntry(this); if (e != null) return (T)e.value; } return setInitialValue(); }
2.
myNode
myNode(ThreadLocal ) CLHLock myPred Thread1 tail myPred (ThreadLocal ) Thread 2 tail (Node) CLHLock : Thread N public void lock() { QNode node = myNode.get(); node.locked = true; QNode pred = tail.getAndSet(node); Thread : myPred.set(pred); CLHLock.lock() while (pred.locked) { doSomeThing(); } CLHLock.unlock(); }
3.
CLHLock: 对象
ThreadLocal myNode myPred :对象域 node :局部变量 CLHLock myPred ThreadLocal myNodeKey : myPred,myNode,tail ThreadLocal myNode tail as Key node QNode QNode locked=true locked=false myNodeKey Thread1 Thread1 : lock() QNode node = myNode.get(); node.locked = true;
4.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node pred QNode QNode locked=true locked=fasle myNodeKey myPredKey Thread1 Thread1 : lock() QNode pred = tail.getAndSet(node); myPred.set(pred); while (pred.locked) { }
5.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node QNode QNode QNode locked=true locked=true locked=fasle myNodeKey myNodeKey myPredKey Thread2 Thread1 Thread2 : lock() QNode node = myNode.get(); Thread1 : node.locked = true; dosomeThing(){ …… }
6.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node pred QNode QNode QNode locked=true locked=true locked=fasle myNodeKey myNodeKey myPredKey myPredKey Thread2 Thread1 Thread2 : lock() Thread1 : QNode pred = tail.getAndSet(node); dosomeThing(){ myPred.set(pred); while (pred.locked) { …… LockSupport.park(this); //block } }
7.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node node pred QNode QNode QNode locked=true locked=false locked=fasle myNodeKey myNodeKey myPredKey myPredKey Thread2 Thread1 Thread2 : lock() Thread1 : unlock () QNode pred = tail.getAndSet(node); QNode node = myNode.get(); myPred.set(pred); node.locked = false; while (pred.locked) { LockSupport.park(this); //block myNode.set(myPred.get()); }
8.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail QNode QNode QNode locked=true locked=false locked=fasle myNodeKey myNodeKey myPredKey myPredKey Thread2 Thread1 Thread2 : Dosomthing(){ }
9.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node QNode QNode QNode locked=false locked=false locked=fasle myNodeKey myNodeKey myPredKey myPredKey Thread2 Thread1 Thread2 : unlock(); QNode node = myNode.get(); node.locked = false; myNode.set(myPred.get());
10.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node QNode QNode QNode locked=false locked=false locked=true myNodeKey myNodeKey myPredKey myPredKey Thread2 Thread1 Thread1 : lock() QNode node = myNode.get(); node.locked = true;
11.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail pred node QNode QNode QNode locked=false locked=false locked=true myPredKey myNodeKey myNodeKey myPredKey Thread2 Thread1 Thread1 : lock() QNode pred = tail.getAndSet(node); myPred.set(pred); while (pred.locked) { }
12.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node QNode QNode QNode locked=false locked=false locked=true myPredKey myNodeKey myNodeKey myPredKey Thread2 Thread1 Thread1 : lock() 后再次调用 lock() QNode node = myNode.get(); node.locked = true;
13.
ThreadLocal
myNode CLHLock myPred ThreadLocal myPred,myNode,tail tail node pred QNode QNode QNode locked=false locked=false locked=true myNodeKey myNodeKey myPredKey myPredKey Thread2 Thread1 Thread1 : lock() QNode pred = tail.getAndSet(node); myPred.set(pred); while (pred.locked) { // 永远 true 不可重入锁 }
Jetzt herunterladen