Skip to content

Commit c6b0f13

Browse files
README.md
create README.md
1 parent 5d6d610 commit c6b0f13

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# java-thread-vs-executor
2+
**JDK VERSION :** JDK 11 - [AMAZON CORRETTO](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html)
3+
4+
---
5+
6+
Examples
7+
------
8+
9+
* Thread
10+
11+
> Thread class and Runnable Interface
12+
13+
> Thread sleep & join & priority
14+
15+
> Thread Synchronization
16+
17+
> Thread Deadlock
18+
19+
> Atomic
20+
21+
> Thread wait & notify
22+
23+
> CountDownLatch
24+
25+
> CyclicBarrier
26+
27+
[example code](https://github.com/serdaralkancode/java-thread-vs-executor/tree/master/src/main/java/tr/salkan/code/java/threadExecutor/example/threads)
28+
29+
* Executor Thread Pooling
30+
31+
> Thread Pooling
32+
33+
> Single Thread Pool
34+
35+
> Fixed Thread Pool
36+
37+
> Cached Thread Pool
38+
39+
> Custom Thread Pool
40+
41+
> BlockingQueue & RejectedExecutionHandler & ThreadFactory & Core and Max Pool size & KeepAlive
42+
43+
[example code](https://github.com/serdaralkancode/java-thread-vs-executor/tree/master/src/main/java/tr/salkan/code/java/threadExecutor/example/executors/create)
44+
45+
* Callable & Future
46+
47+
> Callable & Runnable Object
48+
49+
> Future Object
50+
51+
[example code](https://github.com/serdaralkancode/java-thread-vs-executor/tree/master/src/main/java/tr/salkan/code/java/threadExecutor/example/executors/callableAndFuture)
52+
53+
* CompletableFuture
54+
55+
> runAsync & supplyAsync method
56+
57+
> thenApply & thenAccept & thenRun & thenCompose
58+
59+
> join & get
60+
61+
> allOf & anyOf
62+
63+
> CompletableFuture with Executor
64+
65+
> Exception with exceptionally method
66+
67+
> Exception with handle method
68+
69+
[example code](https://github.com/serdaralkancode/java-thread-vs-executor/tree/master/src/main/java/tr/salkan/code/java/threadExecutor/example/executors/completablefuture)
70+
71+
* Fork/Join Framework
72+
73+
> RecursiveAction
74+
75+
> RecursiveTask
76+
77+
[example code](https://github.com/serdaralkancode/java-thread-vs-executor/tree/master/src/main/java/tr/salkan/code/java/threadExecutor/example/forkJoin)
78+
79+
Resources : [Rules of ThreadPoolExecutor pool size](http://www.bigsoft.co.uk/blog/2009/11/27/rules-of-a-threadpoolexecutor-pool-size)
80+
81+
82+
Here are Sun's rules for thread creation in simple terms:
83+
84+
> If the number of threads is less than the corePoolSize, create a new Thread to run a new task.
85+
86+
> If the number of threads is equal (or greater than) the corePoolSize, put the task into the queue.
87+
88+
> If the queue is full, and the number of threads is less than the maxPoolSize, create a new thread to run tasks in.
89+
90+
> If the queue is full, and the number of threads is greater than or equal to maxPoolSize, reject the task.
91+
92+
The long and the short of it is that new threads are only created when the queue fills up, so if you're using an unbounded queue then the number of threads will not exceed corePoolSize.
93+

0 commit comments

Comments
 (0)