[{"data":1,"prerenderedAt":1874},["ShallowReactive",2],{"tag-asynchronous":3},[4],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"date":11,"layout":12,"subtitle":13,"image":14,"optimized_image":14,"category":15,"tags":16,"author":21,"paginate":7,"body":22,"_type":1868,"_id":1869,"_source":1870,"_file":1871,"_stem":1872,"_extension":1873},"/posts/async-java-completable-vs-reactive","posts",false,"","Asynchronous Programming in Java: CompletableFuture vs Reactive Streams","A deep dive into asynchronous programming in Java comparing CompletableFuture and Reactive Streams, with examples and output.","2024-04-15T11:00:00.000Z","post","Choosing the Right Tool for Concurrency in Modern Java","/assets/img/uploads/java-async.png","code",[15,17,18,19,20],"java","asynchronous","reactive","concurrency","jaimedearcos",{"type":23,"children":24,"toc":1854},"root",[25,53,60,70,77,469,477,485,491,778,785,793,799,807,827,835,853,857,863,898,904,1209,1216,1224,1230,1564,1571,1579,1585,1592,1610,1617,1635,1638,1644,1773,1776,1782,1801,1806,1813,1848],{"type":26,"tag":27,"props":28,"children":29},"element","blockquote",{},[30],{"type":26,"tag":31,"props":32,"children":33},"p",{},[34,37,43,45,51],{"type":35,"value":36},"text","Asynchronous programming enables applications to execute non-blocking operations, crucial for performance in modern, concurrent systems. In Java, two powerful tools are commonly used: ",{"type":26,"tag":15,"props":38,"children":40},{"className":39},[],[41],{"type":35,"value":42},"CompletableFuture",{"type":35,"value":44}," and ",{"type":26,"tag":46,"props":47,"children":48},"strong",{},[49],{"type":35,"value":50},"Reactive Streams",{"type":35,"value":52}," (e.g., Project Reactor or RxJava). In this post, we’ll compare both approaches through real code examples and output results.",{"type":26,"tag":54,"props":55,"children":57},"h2",{"id":56},"_1-completablefuture-javas-built-in-promise-api",[58],{"type":35,"value":59},"1. CompletableFuture: Java’s Built-in Promise API",{"type":26,"tag":31,"props":61,"children":62},{},[63,68],{"type":26,"tag":15,"props":64,"children":66},{"className":65},[],[67],{"type":35,"value":42},{"type":35,"value":69}," is a class introduced in Java 8 to write asynchronous, non-blocking code. It's suitable for simple async flows and integrates well with imperative codebases.",{"type":26,"tag":71,"props":72,"children":74},"h3",{"id":73},"example-1-basic-async-execution",[75],{"type":35,"value":76},"Example 1: Basic Async Execution",{"type":26,"tag":78,"props":79,"children":82},"pre",{"code":80,"language":17,"meta":8,"className":81,"style":8},"import java.util.concurrent.CompletableFuture;\n\npublic class CompletableFutureDemo {\n    public static void main(String[] args) {\n        CompletableFuture\u003CString> future = CompletableFuture.supplyAsync(() -> {\n            sleep(1000);\n            return \"Hello from CompletableFuture!\";\n        });\n\n        future.thenAccept(System.out::println);\n        sleep(1500); // wait for completion\n    }\n\n    static void sleep(long millis) {\n        try { Thread.sleep(millis); } catch (InterruptedException e) { }\n    }\n}\n","language-java shiki shiki-themes github-dark github-light",[83],{"type":26,"tag":15,"props":84,"children":85},{"__ignoreMap":8},[86,104,114,139,189,236,260,280,289,297,326,355,364,372,408,452,460],{"type":26,"tag":87,"props":88,"children":91},"span",{"class":89,"line":90},"line",1,[92,98],{"type":26,"tag":87,"props":93,"children":95},{"style":94},"--shiki-default:#F97583;--shiki-light:#D73A49",[96],{"type":35,"value":97},"import",{"type":26,"tag":87,"props":99,"children":101},{"style":100},"--shiki-default:#E1E4E8;--shiki-light:#24292E",[102],{"type":35,"value":103}," java.util.concurrent.CompletableFuture;\n",{"type":26,"tag":87,"props":105,"children":107},{"class":89,"line":106},2,[108],{"type":26,"tag":87,"props":109,"children":111},{"emptyLinePlaceholder":110},true,[112],{"type":35,"value":113},"\n",{"type":26,"tag":87,"props":115,"children":117},{"class":89,"line":116},3,[118,123,128,134],{"type":26,"tag":87,"props":119,"children":120},{"style":94},[121],{"type":35,"value":122},"public",{"type":26,"tag":87,"props":124,"children":125},{"style":94},[126],{"type":35,"value":127}," class",{"type":26,"tag":87,"props":129,"children":131},{"style":130},"--shiki-default:#B392F0;--shiki-light:#6F42C1",[132],{"type":35,"value":133}," CompletableFutureDemo",{"type":26,"tag":87,"props":135,"children":136},{"style":100},[137],{"type":35,"value":138}," {\n",{"type":26,"tag":87,"props":140,"children":142},{"class":89,"line":141},4,[143,148,153,158,163,168,173,178,184],{"type":26,"tag":87,"props":144,"children":145},{"style":94},[146],{"type":35,"value":147},"    public",{"type":26,"tag":87,"props":149,"children":150},{"style":94},[151],{"type":35,"value":152}," static",{"type":26,"tag":87,"props":154,"children":155},{"style":94},[156],{"type":35,"value":157}," void",{"type":26,"tag":87,"props":159,"children":160},{"style":130},[161],{"type":35,"value":162}," main",{"type":26,"tag":87,"props":164,"children":165},{"style":100},[166],{"type":35,"value":167},"(",{"type":26,"tag":87,"props":169,"children":170},{"style":94},[171],{"type":35,"value":172},"String",{"type":26,"tag":87,"props":174,"children":175},{"style":100},[176],{"type":35,"value":177},"[] ",{"type":26,"tag":87,"props":179,"children":181},{"style":180},"--shiki-default:#FFAB70;--shiki-light:#E36209",[182],{"type":35,"value":183},"args",{"type":26,"tag":87,"props":185,"children":186},{"style":100},[187],{"type":35,"value":188},") {\n",{"type":26,"tag":87,"props":190,"children":192},{"class":89,"line":191},5,[193,198,202,207,212,217,222,227,232],{"type":26,"tag":87,"props":194,"children":195},{"style":100},[196],{"type":35,"value":197},"        CompletableFuture\u003C",{"type":26,"tag":87,"props":199,"children":200},{"style":94},[201],{"type":35,"value":172},{"type":26,"tag":87,"props":203,"children":204},{"style":100},[205],{"type":35,"value":206},"> future ",{"type":26,"tag":87,"props":208,"children":209},{"style":94},[210],{"type":35,"value":211},"=",{"type":26,"tag":87,"props":213,"children":214},{"style":100},[215],{"type":35,"value":216}," CompletableFuture.",{"type":26,"tag":87,"props":218,"children":219},{"style":130},[220],{"type":35,"value":221},"supplyAsync",{"type":26,"tag":87,"props":223,"children":224},{"style":100},[225],{"type":35,"value":226},"(() ",{"type":26,"tag":87,"props":228,"children":229},{"style":94},[230],{"type":35,"value":231},"->",{"type":26,"tag":87,"props":233,"children":234},{"style":100},[235],{"type":35,"value":138},{"type":26,"tag":87,"props":237,"children":239},{"class":89,"line":238},6,[240,245,249,255],{"type":26,"tag":87,"props":241,"children":242},{"style":130},[243],{"type":35,"value":244},"            sleep",{"type":26,"tag":87,"props":246,"children":247},{"style":100},[248],{"type":35,"value":167},{"type":26,"tag":87,"props":250,"children":252},{"style":251},"--shiki-default:#79B8FF;--shiki-light:#005CC5",[253],{"type":35,"value":254},"1000",{"type":26,"tag":87,"props":256,"children":257},{"style":100},[258],{"type":35,"value":259},");\n",{"type":26,"tag":87,"props":261,"children":263},{"class":89,"line":262},7,[264,269,275],{"type":26,"tag":87,"props":265,"children":266},{"style":94},[267],{"type":35,"value":268},"            return",{"type":26,"tag":87,"props":270,"children":272},{"style":271},"--shiki-default:#9ECBFF;--shiki-light:#032F62",[273],{"type":35,"value":274}," \"Hello from CompletableFuture!\"",{"type":26,"tag":87,"props":276,"children":277},{"style":100},[278],{"type":35,"value":279},";\n",{"type":26,"tag":87,"props":281,"children":283},{"class":89,"line":282},8,[284],{"type":26,"tag":87,"props":285,"children":286},{"style":100},[287],{"type":35,"value":288},"        });\n",{"type":26,"tag":87,"props":290,"children":292},{"class":89,"line":291},9,[293],{"type":26,"tag":87,"props":294,"children":295},{"emptyLinePlaceholder":110},[296],{"type":35,"value":113},{"type":26,"tag":87,"props":298,"children":300},{"class":89,"line":299},10,[301,306,311,316,321],{"type":26,"tag":87,"props":302,"children":303},{"style":100},[304],{"type":35,"value":305},"        future.",{"type":26,"tag":87,"props":307,"children":308},{"style":130},[309],{"type":35,"value":310},"thenAccept",{"type":26,"tag":87,"props":312,"children":313},{"style":100},[314],{"type":35,"value":315},"(System.out",{"type":26,"tag":87,"props":317,"children":318},{"style":94},[319],{"type":35,"value":320},"::",{"type":26,"tag":87,"props":322,"children":323},{"style":100},[324],{"type":35,"value":325},"println);\n",{"type":26,"tag":87,"props":327,"children":329},{"class":89,"line":328},11,[330,335,339,344,349],{"type":26,"tag":87,"props":331,"children":332},{"style":130},[333],{"type":35,"value":334},"        sleep",{"type":26,"tag":87,"props":336,"children":337},{"style":100},[338],{"type":35,"value":167},{"type":26,"tag":87,"props":340,"children":341},{"style":251},[342],{"type":35,"value":343},"1500",{"type":26,"tag":87,"props":345,"children":346},{"style":100},[347],{"type":35,"value":348},"); ",{"type":26,"tag":87,"props":350,"children":352},{"style":351},"--shiki-default:#6A737D;--shiki-light:#6A737D",[353],{"type":35,"value":354},"// wait for completion\n",{"type":26,"tag":87,"props":356,"children":358},{"class":89,"line":357},12,[359],{"type":26,"tag":87,"props":360,"children":361},{"style":100},[362],{"type":35,"value":363},"    }\n",{"type":26,"tag":87,"props":365,"children":367},{"class":89,"line":366},13,[368],{"type":26,"tag":87,"props":369,"children":370},{"emptyLinePlaceholder":110},[371],{"type":35,"value":113},{"type":26,"tag":87,"props":373,"children":375},{"class":89,"line":374},14,[376,381,385,390,394,399,404],{"type":26,"tag":87,"props":377,"children":378},{"style":94},[379],{"type":35,"value":380},"    static",{"type":26,"tag":87,"props":382,"children":383},{"style":94},[384],{"type":35,"value":157},{"type":26,"tag":87,"props":386,"children":387},{"style":130},[388],{"type":35,"value":389}," sleep",{"type":26,"tag":87,"props":391,"children":392},{"style":100},[393],{"type":35,"value":167},{"type":26,"tag":87,"props":395,"children":396},{"style":94},[397],{"type":35,"value":398},"long",{"type":26,"tag":87,"props":400,"children":401},{"style":180},[402],{"type":35,"value":403}," millis",{"type":26,"tag":87,"props":405,"children":406},{"style":100},[407],{"type":35,"value":188},{"type":26,"tag":87,"props":409,"children":411},{"class":89,"line":410},15,[412,417,422,427,432,437,442,447],{"type":26,"tag":87,"props":413,"children":414},{"style":94},[415],{"type":35,"value":416},"        try",{"type":26,"tag":87,"props":418,"children":419},{"style":100},[420],{"type":35,"value":421}," { Thread.",{"type":26,"tag":87,"props":423,"children":424},{"style":130},[425],{"type":35,"value":426},"sleep",{"type":26,"tag":87,"props":428,"children":429},{"style":100},[430],{"type":35,"value":431},"(millis); } ",{"type":26,"tag":87,"props":433,"children":434},{"style":94},[435],{"type":35,"value":436},"catch",{"type":26,"tag":87,"props":438,"children":439},{"style":100},[440],{"type":35,"value":441}," (InterruptedException ",{"type":26,"tag":87,"props":443,"children":444},{"style":180},[445],{"type":35,"value":446},"e",{"type":26,"tag":87,"props":448,"children":449},{"style":100},[450],{"type":35,"value":451},") { }\n",{"type":26,"tag":87,"props":453,"children":455},{"class":89,"line":454},16,[456],{"type":26,"tag":87,"props":457,"children":458},{"style":100},[459],{"type":35,"value":363},{"type":26,"tag":87,"props":461,"children":463},{"class":89,"line":462},17,[464],{"type":26,"tag":87,"props":465,"children":466},{"style":100},[467],{"type":35,"value":468},"}\n",{"type":26,"tag":31,"props":470,"children":471},{},[472],{"type":26,"tag":46,"props":473,"children":474},{},[475],{"type":35,"value":476},"Output:",{"type":26,"tag":78,"props":478,"children":480},{"code":479},"Hello from CompletableFuture!\n",[481],{"type":26,"tag":15,"props":482,"children":483},{"__ignoreMap":8},[484],{"type":35,"value":479},{"type":26,"tag":71,"props":486,"children":488},{"id":487},"example-2-chaining-and-combining",[489],{"type":35,"value":490},"Example 2: Chaining and Combining",{"type":26,"tag":78,"props":492,"children":494},{"code":493,"language":17,"meta":8,"className":81,"style":8},"import java.util.concurrent.CompletableFuture;\n\npublic class CompletableFutureCombineDemo {\n    public static void main(String[] args) {\n        CompletableFuture\u003CString> greeting = CompletableFuture.supplyAsync(() -> \"Hello\");\n        CompletableFuture\u003CString> name = CompletableFuture.supplyAsync(() -> \"World\");\n\n        CompletableFuture\u003CString> result = greeting.thenCombine(name, (g, n) -> g + \", \" + n);\n        System.out.println(result.join());\n    }\n}\n",[495],{"type":26,"tag":15,"props":496,"children":497},{"__ignoreMap":8},[498,509,516,536,575,620,665,672,736,764,771],{"type":26,"tag":87,"props":499,"children":500},{"class":89,"line":90},[501,505],{"type":26,"tag":87,"props":502,"children":503},{"style":94},[504],{"type":35,"value":97},{"type":26,"tag":87,"props":506,"children":507},{"style":100},[508],{"type":35,"value":103},{"type":26,"tag":87,"props":510,"children":511},{"class":89,"line":106},[512],{"type":26,"tag":87,"props":513,"children":514},{"emptyLinePlaceholder":110},[515],{"type":35,"value":113},{"type":26,"tag":87,"props":517,"children":518},{"class":89,"line":116},[519,523,527,532],{"type":26,"tag":87,"props":520,"children":521},{"style":94},[522],{"type":35,"value":122},{"type":26,"tag":87,"props":524,"children":525},{"style":94},[526],{"type":35,"value":127},{"type":26,"tag":87,"props":528,"children":529},{"style":130},[530],{"type":35,"value":531}," CompletableFutureCombineDemo",{"type":26,"tag":87,"props":533,"children":534},{"style":100},[535],{"type":35,"value":138},{"type":26,"tag":87,"props":537,"children":538},{"class":89,"line":141},[539,543,547,551,555,559,563,567,571],{"type":26,"tag":87,"props":540,"children":541},{"style":94},[542],{"type":35,"value":147},{"type":26,"tag":87,"props":544,"children":545},{"style":94},[546],{"type":35,"value":152},{"type":26,"tag":87,"props":548,"children":549},{"style":94},[550],{"type":35,"value":157},{"type":26,"tag":87,"props":552,"children":553},{"style":130},[554],{"type":35,"value":162},{"type":26,"tag":87,"props":556,"children":557},{"style":100},[558],{"type":35,"value":167},{"type":26,"tag":87,"props":560,"children":561},{"style":94},[562],{"type":35,"value":172},{"type":26,"tag":87,"props":564,"children":565},{"style":100},[566],{"type":35,"value":177},{"type":26,"tag":87,"props":568,"children":569},{"style":180},[570],{"type":35,"value":183},{"type":26,"tag":87,"props":572,"children":573},{"style":100},[574],{"type":35,"value":188},{"type":26,"tag":87,"props":576,"children":577},{"class":89,"line":191},[578,582,586,591,595,599,603,607,611,616],{"type":26,"tag":87,"props":579,"children":580},{"style":100},[581],{"type":35,"value":197},{"type":26,"tag":87,"props":583,"children":584},{"style":94},[585],{"type":35,"value":172},{"type":26,"tag":87,"props":587,"children":588},{"style":100},[589],{"type":35,"value":590},"> greeting ",{"type":26,"tag":87,"props":592,"children":593},{"style":94},[594],{"type":35,"value":211},{"type":26,"tag":87,"props":596,"children":597},{"style":100},[598],{"type":35,"value":216},{"type":26,"tag":87,"props":600,"children":601},{"style":130},[602],{"type":35,"value":221},{"type":26,"tag":87,"props":604,"children":605},{"style":100},[606],{"type":35,"value":226},{"type":26,"tag":87,"props":608,"children":609},{"style":94},[610],{"type":35,"value":231},{"type":26,"tag":87,"props":612,"children":613},{"style":271},[614],{"type":35,"value":615}," \"Hello\"",{"type":26,"tag":87,"props":617,"children":618},{"style":100},[619],{"type":35,"value":259},{"type":26,"tag":87,"props":621,"children":622},{"class":89,"line":238},[623,627,631,636,640,644,648,652,656,661],{"type":26,"tag":87,"props":624,"children":625},{"style":100},[626],{"type":35,"value":197},{"type":26,"tag":87,"props":628,"children":629},{"style":94},[630],{"type":35,"value":172},{"type":26,"tag":87,"props":632,"children":633},{"style":100},[634],{"type":35,"value":635},"> name ",{"type":26,"tag":87,"props":637,"children":638},{"style":94},[639],{"type":35,"value":211},{"type":26,"tag":87,"props":641,"children":642},{"style":100},[643],{"type":35,"value":216},{"type":26,"tag":87,"props":645,"children":646},{"style":130},[647],{"type":35,"value":221},{"type":26,"tag":87,"props":649,"children":650},{"style":100},[651],{"type":35,"value":226},{"type":26,"tag":87,"props":653,"children":654},{"style":94},[655],{"type":35,"value":231},{"type":26,"tag":87,"props":657,"children":658},{"style":271},[659],{"type":35,"value":660}," \"World\"",{"type":26,"tag":87,"props":662,"children":663},{"style":100},[664],{"type":35,"value":259},{"type":26,"tag":87,"props":666,"children":667},{"class":89,"line":262},[668],{"type":26,"tag":87,"props":669,"children":670},{"emptyLinePlaceholder":110},[671],{"type":35,"value":113},{"type":26,"tag":87,"props":673,"children":674},{"class":89,"line":282},[675,679,683,688,692,697,702,707,711,716,721,726,731],{"type":26,"tag":87,"props":676,"children":677},{"style":100},[678],{"type":35,"value":197},{"type":26,"tag":87,"props":680,"children":681},{"style":94},[682],{"type":35,"value":172},{"type":26,"tag":87,"props":684,"children":685},{"style":100},[686],{"type":35,"value":687},"> result ",{"type":26,"tag":87,"props":689,"children":690},{"style":94},[691],{"type":35,"value":211},{"type":26,"tag":87,"props":693,"children":694},{"style":100},[695],{"type":35,"value":696}," greeting.",{"type":26,"tag":87,"props":698,"children":699},{"style":130},[700],{"type":35,"value":701},"thenCombine",{"type":26,"tag":87,"props":703,"children":704},{"style":100},[705],{"type":35,"value":706},"(name, (g, n) ",{"type":26,"tag":87,"props":708,"children":709},{"style":94},[710],{"type":35,"value":231},{"type":26,"tag":87,"props":712,"children":713},{"style":100},[714],{"type":35,"value":715}," g ",{"type":26,"tag":87,"props":717,"children":718},{"style":94},[719],{"type":35,"value":720},"+",{"type":26,"tag":87,"props":722,"children":723},{"style":271},[724],{"type":35,"value":725}," \", \"",{"type":26,"tag":87,"props":727,"children":728},{"style":94},[729],{"type":35,"value":730}," +",{"type":26,"tag":87,"props":732,"children":733},{"style":100},[734],{"type":35,"value":735}," n);\n",{"type":26,"tag":87,"props":737,"children":738},{"class":89,"line":291},[739,744,749,754,759],{"type":26,"tag":87,"props":740,"children":741},{"style":100},[742],{"type":35,"value":743},"        System.out.",{"type":26,"tag":87,"props":745,"children":746},{"style":130},[747],{"type":35,"value":748},"println",{"type":26,"tag":87,"props":750,"children":751},{"style":100},[752],{"type":35,"value":753},"(result.",{"type":26,"tag":87,"props":755,"children":756},{"style":130},[757],{"type":35,"value":758},"join",{"type":26,"tag":87,"props":760,"children":761},{"style":100},[762],{"type":35,"value":763},"());\n",{"type":26,"tag":87,"props":765,"children":766},{"class":89,"line":299},[767],{"type":26,"tag":87,"props":768,"children":769},{"style":100},[770],{"type":35,"value":363},{"type":26,"tag":87,"props":772,"children":773},{"class":89,"line":328},[774],{"type":26,"tag":87,"props":775,"children":776},{"style":100},[777],{"type":35,"value":468},{"type":26,"tag":31,"props":779,"children":780},{},[781],{"type":26,"tag":46,"props":782,"children":783},{},[784],{"type":35,"value":476},{"type":26,"tag":78,"props":786,"children":788},{"code":787},"Hello, World\n",[789],{"type":26,"tag":15,"props":790,"children":791},{"__ignoreMap":8},[792],{"type":35,"value":787},{"type":26,"tag":71,"props":794,"children":796},{"id":795},"pros-and-cons-of-completablefuture",[797],{"type":35,"value":798},"Pros and Cons of CompletableFuture",{"type":26,"tag":31,"props":800,"children":801},{},[802],{"type":26,"tag":46,"props":803,"children":804},{},[805],{"type":35,"value":806},"Pros:",{"type":26,"tag":808,"props":809,"children":810},"ul",{},[811,817,822],{"type":26,"tag":812,"props":813,"children":814},"li",{},[815],{"type":35,"value":816},"Native Java API, no dependencies",{"type":26,"tag":812,"props":818,"children":819},{},[820],{"type":35,"value":821},"Familiar to imperative developers",{"type":26,"tag":812,"props":823,"children":824},{},[825],{"type":35,"value":826},"Easy for linear async flows",{"type":26,"tag":31,"props":828,"children":829},{},[830],{"type":26,"tag":46,"props":831,"children":832},{},[833],{"type":35,"value":834},"Cons:",{"type":26,"tag":808,"props":836,"children":837},{},[838,843,848],{"type":26,"tag":812,"props":839,"children":840},{},[841],{"type":35,"value":842},"Limited operators compared to reactive libraries",{"type":26,"tag":812,"props":844,"children":845},{},[846],{"type":35,"value":847},"Complex error handling in larger flows",{"type":26,"tag":812,"props":849,"children":850},{},[851],{"type":35,"value":852},"Not suitable for high-throughput event streams",{"type":26,"tag":854,"props":855,"children":856},"hr",{},[],{"type":26,"tag":54,"props":858,"children":860},{"id":859},"_2-reactive-streams-declarative-and-event-driven",[861],{"type":35,"value":862},"2. Reactive Streams: Declarative and Event-Driven",{"type":26,"tag":31,"props":864,"children":865},{},[866,868,873,875,881,883,889,891,896],{"type":35,"value":867},"Reactive programming models async execution as a stream of data. With libraries like ",{"type":26,"tag":46,"props":869,"children":870},{},[871],{"type":35,"value":872},"Project Reactor",{"type":35,"value":874}," (",{"type":26,"tag":15,"props":876,"children":878},{"className":877},[],[879],{"type":35,"value":880},"Mono",{"type":35,"value":882},", ",{"type":26,"tag":15,"props":884,"children":886},{"className":885},[],[887],{"type":35,"value":888},"Flux",{"type":35,"value":890},") or ",{"type":26,"tag":46,"props":892,"children":893},{},[894],{"type":35,"value":895},"RxJava",{"type":35,"value":897},", you can build pipelines to transform, filter, and combine async data.",{"type":26,"tag":71,"props":899,"children":901},{"id":900},"example-1-mono-single-async-value",[902],{"type":35,"value":903},"Example 1: Mono (Single Async Value)",{"type":26,"tag":78,"props":905,"children":907},{"code":906,"language":17,"meta":8,"className":81,"style":8},"import reactor.core.publisher.Mono;\nimport java.time.Duration;\n\npublic class ReactorMonoExample {\n    public static void main(String[] args) {\n        Mono.just(\"Hello from Mono!\")\n            .delayElement(Duration.ofMillis(500))\n            .subscribe(System.out::println);\n\n        sleep(1000);\n    }\n\n    static void sleep(long millis) {\n        try { Thread.sleep(millis); } catch (InterruptedException e) { }\n    }\n}\n",[908],{"type":26,"tag":15,"props":909,"children":910},{"__ignoreMap":8},[911,923,935,942,962,1001,1028,1065,1089,1096,1115,1122,1129,1160,1195,1202],{"type":26,"tag":87,"props":912,"children":913},{"class":89,"line":90},[914,918],{"type":26,"tag":87,"props":915,"children":916},{"style":94},[917],{"type":35,"value":97},{"type":26,"tag":87,"props":919,"children":920},{"style":100},[921],{"type":35,"value":922}," reactor.core.publisher.Mono;\n",{"type":26,"tag":87,"props":924,"children":925},{"class":89,"line":106},[926,930],{"type":26,"tag":87,"props":927,"children":928},{"style":94},[929],{"type":35,"value":97},{"type":26,"tag":87,"props":931,"children":932},{"style":100},[933],{"type":35,"value":934}," java.time.Duration;\n",{"type":26,"tag":87,"props":936,"children":937},{"class":89,"line":116},[938],{"type":26,"tag":87,"props":939,"children":940},{"emptyLinePlaceholder":110},[941],{"type":35,"value":113},{"type":26,"tag":87,"props":943,"children":944},{"class":89,"line":141},[945,949,953,958],{"type":26,"tag":87,"props":946,"children":947},{"style":94},[948],{"type":35,"value":122},{"type":26,"tag":87,"props":950,"children":951},{"style":94},[952],{"type":35,"value":127},{"type":26,"tag":87,"props":954,"children":955},{"style":130},[956],{"type":35,"value":957}," ReactorMonoExample",{"type":26,"tag":87,"props":959,"children":960},{"style":100},[961],{"type":35,"value":138},{"type":26,"tag":87,"props":963,"children":964},{"class":89,"line":191},[965,969,973,977,981,985,989,993,997],{"type":26,"tag":87,"props":966,"children":967},{"style":94},[968],{"type":35,"value":147},{"type":26,"tag":87,"props":970,"children":971},{"style":94},[972],{"type":35,"value":152},{"type":26,"tag":87,"props":974,"children":975},{"style":94},[976],{"type":35,"value":157},{"type":26,"tag":87,"props":978,"children":979},{"style":130},[980],{"type":35,"value":162},{"type":26,"tag":87,"props":982,"children":983},{"style":100},[984],{"type":35,"value":167},{"type":26,"tag":87,"props":986,"children":987},{"style":94},[988],{"type":35,"value":172},{"type":26,"tag":87,"props":990,"children":991},{"style":100},[992],{"type":35,"value":177},{"type":26,"tag":87,"props":994,"children":995},{"style":180},[996],{"type":35,"value":183},{"type":26,"tag":87,"props":998,"children":999},{"style":100},[1000],{"type":35,"value":188},{"type":26,"tag":87,"props":1002,"children":1003},{"class":89,"line":238},[1004,1009,1014,1018,1023],{"type":26,"tag":87,"props":1005,"children":1006},{"style":100},[1007],{"type":35,"value":1008},"        Mono.",{"type":26,"tag":87,"props":1010,"children":1011},{"style":130},[1012],{"type":35,"value":1013},"just",{"type":26,"tag":87,"props":1015,"children":1016},{"style":100},[1017],{"type":35,"value":167},{"type":26,"tag":87,"props":1019,"children":1020},{"style":271},[1021],{"type":35,"value":1022},"\"Hello from Mono!\"",{"type":26,"tag":87,"props":1024,"children":1025},{"style":100},[1026],{"type":35,"value":1027},")\n",{"type":26,"tag":87,"props":1029,"children":1030},{"class":89,"line":262},[1031,1036,1041,1046,1051,1055,1060],{"type":26,"tag":87,"props":1032,"children":1033},{"style":100},[1034],{"type":35,"value":1035},"            .",{"type":26,"tag":87,"props":1037,"children":1038},{"style":130},[1039],{"type":35,"value":1040},"delayElement",{"type":26,"tag":87,"props":1042,"children":1043},{"style":100},[1044],{"type":35,"value":1045},"(Duration.",{"type":26,"tag":87,"props":1047,"children":1048},{"style":130},[1049],{"type":35,"value":1050},"ofMillis",{"type":26,"tag":87,"props":1052,"children":1053},{"style":100},[1054],{"type":35,"value":167},{"type":26,"tag":87,"props":1056,"children":1057},{"style":251},[1058],{"type":35,"value":1059},"500",{"type":26,"tag":87,"props":1061,"children":1062},{"style":100},[1063],{"type":35,"value":1064},"))\n",{"type":26,"tag":87,"props":1066,"children":1067},{"class":89,"line":282},[1068,1072,1077,1081,1085],{"type":26,"tag":87,"props":1069,"children":1070},{"style":100},[1071],{"type":35,"value":1035},{"type":26,"tag":87,"props":1073,"children":1074},{"style":130},[1075],{"type":35,"value":1076},"subscribe",{"type":26,"tag":87,"props":1078,"children":1079},{"style":100},[1080],{"type":35,"value":315},{"type":26,"tag":87,"props":1082,"children":1083},{"style":94},[1084],{"type":35,"value":320},{"type":26,"tag":87,"props":1086,"children":1087},{"style":100},[1088],{"type":35,"value":325},{"type":26,"tag":87,"props":1090,"children":1091},{"class":89,"line":291},[1092],{"type":26,"tag":87,"props":1093,"children":1094},{"emptyLinePlaceholder":110},[1095],{"type":35,"value":113},{"type":26,"tag":87,"props":1097,"children":1098},{"class":89,"line":299},[1099,1103,1107,1111],{"type":26,"tag":87,"props":1100,"children":1101},{"style":130},[1102],{"type":35,"value":334},{"type":26,"tag":87,"props":1104,"children":1105},{"style":100},[1106],{"type":35,"value":167},{"type":26,"tag":87,"props":1108,"children":1109},{"style":251},[1110],{"type":35,"value":254},{"type":26,"tag":87,"props":1112,"children":1113},{"style":100},[1114],{"type":35,"value":259},{"type":26,"tag":87,"props":1116,"children":1117},{"class":89,"line":328},[1118],{"type":26,"tag":87,"props":1119,"children":1120},{"style":100},[1121],{"type":35,"value":363},{"type":26,"tag":87,"props":1123,"children":1124},{"class":89,"line":357},[1125],{"type":26,"tag":87,"props":1126,"children":1127},{"emptyLinePlaceholder":110},[1128],{"type":35,"value":113},{"type":26,"tag":87,"props":1130,"children":1131},{"class":89,"line":366},[1132,1136,1140,1144,1148,1152,1156],{"type":26,"tag":87,"props":1133,"children":1134},{"style":94},[1135],{"type":35,"value":380},{"type":26,"tag":87,"props":1137,"children":1138},{"style":94},[1139],{"type":35,"value":157},{"type":26,"tag":87,"props":1141,"children":1142},{"style":130},[1143],{"type":35,"value":389},{"type":26,"tag":87,"props":1145,"children":1146},{"style":100},[1147],{"type":35,"value":167},{"type":26,"tag":87,"props":1149,"children":1150},{"style":94},[1151],{"type":35,"value":398},{"type":26,"tag":87,"props":1153,"children":1154},{"style":180},[1155],{"type":35,"value":403},{"type":26,"tag":87,"props":1157,"children":1158},{"style":100},[1159],{"type":35,"value":188},{"type":26,"tag":87,"props":1161,"children":1162},{"class":89,"line":374},[1163,1167,1171,1175,1179,1183,1187,1191],{"type":26,"tag":87,"props":1164,"children":1165},{"style":94},[1166],{"type":35,"value":416},{"type":26,"tag":87,"props":1168,"children":1169},{"style":100},[1170],{"type":35,"value":421},{"type":26,"tag":87,"props":1172,"children":1173},{"style":130},[1174],{"type":35,"value":426},{"type":26,"tag":87,"props":1176,"children":1177},{"style":100},[1178],{"type":35,"value":431},{"type":26,"tag":87,"props":1180,"children":1181},{"style":94},[1182],{"type":35,"value":436},{"type":26,"tag":87,"props":1184,"children":1185},{"style":100},[1186],{"type":35,"value":441},{"type":26,"tag":87,"props":1188,"children":1189},{"style":180},[1190],{"type":35,"value":446},{"type":26,"tag":87,"props":1192,"children":1193},{"style":100},[1194],{"type":35,"value":451},{"type":26,"tag":87,"props":1196,"children":1197},{"class":89,"line":410},[1198],{"type":26,"tag":87,"props":1199,"children":1200},{"style":100},[1201],{"type":35,"value":363},{"type":26,"tag":87,"props":1203,"children":1204},{"class":89,"line":454},[1205],{"type":26,"tag":87,"props":1206,"children":1207},{"style":100},[1208],{"type":35,"value":468},{"type":26,"tag":31,"props":1210,"children":1211},{},[1212],{"type":26,"tag":46,"props":1213,"children":1214},{},[1215],{"type":35,"value":476},{"type":26,"tag":78,"props":1217,"children":1219},{"code":1218},"Hello from Mono!\n",[1220],{"type":26,"tag":15,"props":1221,"children":1222},{"__ignoreMap":8},[1223],{"type":35,"value":1218},{"type":26,"tag":71,"props":1225,"children":1227},{"id":1226},"example-2-flux-multiple-async-events",[1228],{"type":35,"value":1229},"Example 2: Flux (Multiple Async Events)",{"type":26,"tag":78,"props":1231,"children":1233},{"code":1232,"language":17,"meta":8,"className":81,"style":8},"import reactor.core.publisher.Flux;\nimport java.time.Duration;\n\npublic class ReactorFluxExample {\n    public static void main(String[] args) {\n        Flux.interval(Duration.ofMillis(300))\n            .take(5)\n            .map(i -> \"Tick \" + i)\n            .subscribe(System.out::println);\n\n        sleep(2000);\n    }\n\n    static void sleep(long millis) {\n        try { Thread.sleep(millis); } catch (InterruptedException e) { }\n    }\n}\n",[1234],{"type":26,"tag":15,"props":1235,"children":1236},{"__ignoreMap":8},[1237,1249,1260,1267,1287,1326,1360,1385,1420,1443,1450,1470,1477,1484,1515,1550,1557],{"type":26,"tag":87,"props":1238,"children":1239},{"class":89,"line":90},[1240,1244],{"type":26,"tag":87,"props":1241,"children":1242},{"style":94},[1243],{"type":35,"value":97},{"type":26,"tag":87,"props":1245,"children":1246},{"style":100},[1247],{"type":35,"value":1248}," reactor.core.publisher.Flux;\n",{"type":26,"tag":87,"props":1250,"children":1251},{"class":89,"line":106},[1252,1256],{"type":26,"tag":87,"props":1253,"children":1254},{"style":94},[1255],{"type":35,"value":97},{"type":26,"tag":87,"props":1257,"children":1258},{"style":100},[1259],{"type":35,"value":934},{"type":26,"tag":87,"props":1261,"children":1262},{"class":89,"line":116},[1263],{"type":26,"tag":87,"props":1264,"children":1265},{"emptyLinePlaceholder":110},[1266],{"type":35,"value":113},{"type":26,"tag":87,"props":1268,"children":1269},{"class":89,"line":141},[1270,1274,1278,1283],{"type":26,"tag":87,"props":1271,"children":1272},{"style":94},[1273],{"type":35,"value":122},{"type":26,"tag":87,"props":1275,"children":1276},{"style":94},[1277],{"type":35,"value":127},{"type":26,"tag":87,"props":1279,"children":1280},{"style":130},[1281],{"type":35,"value":1282}," ReactorFluxExample",{"type":26,"tag":87,"props":1284,"children":1285},{"style":100},[1286],{"type":35,"value":138},{"type":26,"tag":87,"props":1288,"children":1289},{"class":89,"line":191},[1290,1294,1298,1302,1306,1310,1314,1318,1322],{"type":26,"tag":87,"props":1291,"children":1292},{"style":94},[1293],{"type":35,"value":147},{"type":26,"tag":87,"props":1295,"children":1296},{"style":94},[1297],{"type":35,"value":152},{"type":26,"tag":87,"props":1299,"children":1300},{"style":94},[1301],{"type":35,"value":157},{"type":26,"tag":87,"props":1303,"children":1304},{"style":130},[1305],{"type":35,"value":162},{"type":26,"tag":87,"props":1307,"children":1308},{"style":100},[1309],{"type":35,"value":167},{"type":26,"tag":87,"props":1311,"children":1312},{"style":94},[1313],{"type":35,"value":172},{"type":26,"tag":87,"props":1315,"children":1316},{"style":100},[1317],{"type":35,"value":177},{"type":26,"tag":87,"props":1319,"children":1320},{"style":180},[1321],{"type":35,"value":183},{"type":26,"tag":87,"props":1323,"children":1324},{"style":100},[1325],{"type":35,"value":188},{"type":26,"tag":87,"props":1327,"children":1328},{"class":89,"line":238},[1329,1334,1339,1343,1347,1351,1356],{"type":26,"tag":87,"props":1330,"children":1331},{"style":100},[1332],{"type":35,"value":1333},"        Flux.",{"type":26,"tag":87,"props":1335,"children":1336},{"style":130},[1337],{"type":35,"value":1338},"interval",{"type":26,"tag":87,"props":1340,"children":1341},{"style":100},[1342],{"type":35,"value":1045},{"type":26,"tag":87,"props":1344,"children":1345},{"style":130},[1346],{"type":35,"value":1050},{"type":26,"tag":87,"props":1348,"children":1349},{"style":100},[1350],{"type":35,"value":167},{"type":26,"tag":87,"props":1352,"children":1353},{"style":251},[1354],{"type":35,"value":1355},"300",{"type":26,"tag":87,"props":1357,"children":1358},{"style":100},[1359],{"type":35,"value":1064},{"type":26,"tag":87,"props":1361,"children":1362},{"class":89,"line":262},[1363,1367,1372,1376,1381],{"type":26,"tag":87,"props":1364,"children":1365},{"style":100},[1366],{"type":35,"value":1035},{"type":26,"tag":87,"props":1368,"children":1369},{"style":130},[1370],{"type":35,"value":1371},"take",{"type":26,"tag":87,"props":1373,"children":1374},{"style":100},[1375],{"type":35,"value":167},{"type":26,"tag":87,"props":1377,"children":1378},{"style":251},[1379],{"type":35,"value":1380},"5",{"type":26,"tag":87,"props":1382,"children":1383},{"style":100},[1384],{"type":35,"value":1027},{"type":26,"tag":87,"props":1386,"children":1387},{"class":89,"line":282},[1388,1392,1397,1402,1406,1411,1415],{"type":26,"tag":87,"props":1389,"children":1390},{"style":100},[1391],{"type":35,"value":1035},{"type":26,"tag":87,"props":1393,"children":1394},{"style":130},[1395],{"type":35,"value":1396},"map",{"type":26,"tag":87,"props":1398,"children":1399},{"style":100},[1400],{"type":35,"value":1401},"(i ",{"type":26,"tag":87,"props":1403,"children":1404},{"style":94},[1405],{"type":35,"value":231},{"type":26,"tag":87,"props":1407,"children":1408},{"style":271},[1409],{"type":35,"value":1410}," \"Tick \"",{"type":26,"tag":87,"props":1412,"children":1413},{"style":94},[1414],{"type":35,"value":730},{"type":26,"tag":87,"props":1416,"children":1417},{"style":100},[1418],{"type":35,"value":1419}," i)\n",{"type":26,"tag":87,"props":1421,"children":1422},{"class":89,"line":291},[1423,1427,1431,1435,1439],{"type":26,"tag":87,"props":1424,"children":1425},{"style":100},[1426],{"type":35,"value":1035},{"type":26,"tag":87,"props":1428,"children":1429},{"style":130},[1430],{"type":35,"value":1076},{"type":26,"tag":87,"props":1432,"children":1433},{"style":100},[1434],{"type":35,"value":315},{"type":26,"tag":87,"props":1436,"children":1437},{"style":94},[1438],{"type":35,"value":320},{"type":26,"tag":87,"props":1440,"children":1441},{"style":100},[1442],{"type":35,"value":325},{"type":26,"tag":87,"props":1444,"children":1445},{"class":89,"line":299},[1446],{"type":26,"tag":87,"props":1447,"children":1448},{"emptyLinePlaceholder":110},[1449],{"type":35,"value":113},{"type":26,"tag":87,"props":1451,"children":1452},{"class":89,"line":328},[1453,1457,1461,1466],{"type":26,"tag":87,"props":1454,"children":1455},{"style":130},[1456],{"type":35,"value":334},{"type":26,"tag":87,"props":1458,"children":1459},{"style":100},[1460],{"type":35,"value":167},{"type":26,"tag":87,"props":1462,"children":1463},{"style":251},[1464],{"type":35,"value":1465},"2000",{"type":26,"tag":87,"props":1467,"children":1468},{"style":100},[1469],{"type":35,"value":259},{"type":26,"tag":87,"props":1471,"children":1472},{"class":89,"line":357},[1473],{"type":26,"tag":87,"props":1474,"children":1475},{"style":100},[1476],{"type":35,"value":363},{"type":26,"tag":87,"props":1478,"children":1479},{"class":89,"line":366},[1480],{"type":26,"tag":87,"props":1481,"children":1482},{"emptyLinePlaceholder":110},[1483],{"type":35,"value":113},{"type":26,"tag":87,"props":1485,"children":1486},{"class":89,"line":374},[1487,1491,1495,1499,1503,1507,1511],{"type":26,"tag":87,"props":1488,"children":1489},{"style":94},[1490],{"type":35,"value":380},{"type":26,"tag":87,"props":1492,"children":1493},{"style":94},[1494],{"type":35,"value":157},{"type":26,"tag":87,"props":1496,"children":1497},{"style":130},[1498],{"type":35,"value":389},{"type":26,"tag":87,"props":1500,"children":1501},{"style":100},[1502],{"type":35,"value":167},{"type":26,"tag":87,"props":1504,"children":1505},{"style":94},[1506],{"type":35,"value":398},{"type":26,"tag":87,"props":1508,"children":1509},{"style":180},[1510],{"type":35,"value":403},{"type":26,"tag":87,"props":1512,"children":1513},{"style":100},[1514],{"type":35,"value":188},{"type":26,"tag":87,"props":1516,"children":1517},{"class":89,"line":410},[1518,1522,1526,1530,1534,1538,1542,1546],{"type":26,"tag":87,"props":1519,"children":1520},{"style":94},[1521],{"type":35,"value":416},{"type":26,"tag":87,"props":1523,"children":1524},{"style":100},[1525],{"type":35,"value":421},{"type":26,"tag":87,"props":1527,"children":1528},{"style":130},[1529],{"type":35,"value":426},{"type":26,"tag":87,"props":1531,"children":1532},{"style":100},[1533],{"type":35,"value":431},{"type":26,"tag":87,"props":1535,"children":1536},{"style":94},[1537],{"type":35,"value":436},{"type":26,"tag":87,"props":1539,"children":1540},{"style":100},[1541],{"type":35,"value":441},{"type":26,"tag":87,"props":1543,"children":1544},{"style":180},[1545],{"type":35,"value":446},{"type":26,"tag":87,"props":1547,"children":1548},{"style":100},[1549],{"type":35,"value":451},{"type":26,"tag":87,"props":1551,"children":1552},{"class":89,"line":454},[1553],{"type":26,"tag":87,"props":1554,"children":1555},{"style":100},[1556],{"type":35,"value":363},{"type":26,"tag":87,"props":1558,"children":1559},{"class":89,"line":462},[1560],{"type":26,"tag":87,"props":1561,"children":1562},{"style":100},[1563],{"type":35,"value":468},{"type":26,"tag":31,"props":1565,"children":1566},{},[1567],{"type":26,"tag":46,"props":1568,"children":1569},{},[1570],{"type":35,"value":476},{"type":26,"tag":78,"props":1572,"children":1574},{"code":1573},"Tick 0\nTick 1\nTick 2\nTick 3\nTick 4\n",[1575],{"type":26,"tag":15,"props":1576,"children":1577},{"__ignoreMap":8},[1578],{"type":35,"value":1573},{"type":26,"tag":71,"props":1580,"children":1582},{"id":1581},"pros-and-cons-of-reactive-streams",[1583],{"type":35,"value":1584},"Pros and Cons of Reactive Streams",{"type":26,"tag":31,"props":1586,"children":1587},{},[1588],{"type":26,"tag":46,"props":1589,"children":1590},{},[1591],{"type":35,"value":806},{"type":26,"tag":808,"props":1593,"children":1594},{},[1595,1600,1605],{"type":26,"tag":812,"props":1596,"children":1597},{},[1598],{"type":35,"value":1599},"Rich operator set for complex flows",{"type":26,"tag":812,"props":1601,"children":1602},{},[1603],{"type":35,"value":1604},"Built-in backpressure handling",{"type":26,"tag":812,"props":1606,"children":1607},{},[1608],{"type":35,"value":1609},"Ideal for data streams and event-driven apps",{"type":26,"tag":31,"props":1611,"children":1612},{},[1613],{"type":26,"tag":46,"props":1614,"children":1615},{},[1616],{"type":35,"value":834},{"type":26,"tag":808,"props":1618,"children":1619},{},[1620,1625,1630],{"type":26,"tag":812,"props":1621,"children":1622},{},[1623],{"type":35,"value":1624},"Requires learning new paradigm",{"type":26,"tag":812,"props":1626,"children":1627},{},[1628],{"type":35,"value":1629},"Can be overkill for simple use cases",{"type":26,"tag":812,"props":1631,"children":1632},{},[1633],{"type":35,"value":1634},"More dependencies (Reactor, RxJava)",{"type":26,"tag":854,"props":1636,"children":1637},{},[],{"type":26,"tag":54,"props":1639,"children":1641},{"id":1640},"_3-when-to-use-each",[1642],{"type":35,"value":1643},"3. When to Use Each?",{"type":26,"tag":1645,"props":1646,"children":1647},"table",{},[1648,1670],{"type":26,"tag":1649,"props":1650,"children":1651},"thead",{},[1652],{"type":26,"tag":1653,"props":1654,"children":1655},"tr",{},[1656,1662,1666],{"type":26,"tag":1657,"props":1658,"children":1659},"th",{},[1660],{"type":35,"value":1661},"Use Case",{"type":26,"tag":1657,"props":1663,"children":1664},{},[1665],{"type":35,"value":42},{"type":26,"tag":1657,"props":1667,"children":1668},{},[1669],{"type":35,"value":50},{"type":26,"tag":1671,"props":1672,"children":1673},"tbody",{},[1674,1693,1709,1725,1741,1757],{"type":26,"tag":1653,"props":1675,"children":1676},{},[1677,1683,1688],{"type":26,"tag":1678,"props":1679,"children":1680},"td",{},[1681],{"type":35,"value":1682},"Simple async call",{"type":26,"tag":1678,"props":1684,"children":1685},{},[1686],{"type":35,"value":1687},"✅",{"type":26,"tag":1678,"props":1689,"children":1690},{},[1691],{"type":35,"value":1692},"❌",{"type":26,"tag":1653,"props":1694,"children":1695},{},[1696,1701,1705],{"type":26,"tag":1678,"props":1697,"children":1698},{},[1699],{"type":35,"value":1700},"API call + transform",{"type":26,"tag":1678,"props":1702,"children":1703},{},[1704],{"type":35,"value":1687},{"type":26,"tag":1678,"props":1706,"children":1707},{},[1708],{"type":35,"value":1687},{"type":26,"tag":1653,"props":1710,"children":1711},{},[1712,1717,1721],{"type":26,"tag":1678,"props":1713,"children":1714},{},[1715],{"type":35,"value":1716},"Data pipeline (streaming)",{"type":26,"tag":1678,"props":1718,"children":1719},{},[1720],{"type":35,"value":1692},{"type":26,"tag":1678,"props":1722,"children":1723},{},[1724],{"type":35,"value":1687},{"type":26,"tag":1653,"props":1726,"children":1727},{},[1728,1733,1737],{"type":26,"tag":1678,"props":1729,"children":1730},{},[1731],{"type":35,"value":1732},"Reactive UI/backend",{"type":26,"tag":1678,"props":1734,"children":1735},{},[1736],{"type":35,"value":1692},{"type":26,"tag":1678,"props":1738,"children":1739},{},[1740],{"type":35,"value":1687},{"type":26,"tag":1653,"props":1742,"children":1743},{},[1744,1749,1753],{"type":26,"tag":1678,"props":1745,"children":1746},{},[1747],{"type":35,"value":1748},"Minimal dependencies",{"type":26,"tag":1678,"props":1750,"children":1751},{},[1752],{"type":35,"value":1687},{"type":26,"tag":1678,"props":1754,"children":1755},{},[1756],{"type":35,"value":1692},{"type":26,"tag":1653,"props":1758,"children":1759},{},[1760,1765,1769],{"type":26,"tag":1678,"props":1761,"children":1762},{},[1763],{"type":35,"value":1764},"Advanced composition",{"type":26,"tag":1678,"props":1766,"children":1767},{},[1768],{"type":35,"value":1692},{"type":26,"tag":1678,"props":1770,"children":1771},{},[1772],{"type":35,"value":1687},{"type":26,"tag":854,"props":1774,"children":1775},{},[],{"type":26,"tag":54,"props":1777,"children":1779},{"id":1778},"conclusion",[1780],{"type":35,"value":1781},"Conclusion",{"type":26,"tag":31,"props":1783,"children":1784},{},[1785,1787,1792,1794,1799],{"type":35,"value":1786},"Both ",{"type":26,"tag":15,"props":1788,"children":1790},{"className":1789},[],[1791],{"type":35,"value":42},{"type":35,"value":1793}," and Reactive Streams serve asynchronous needs, but they excel in different areas. For straightforward async calls, ",{"type":26,"tag":15,"props":1795,"children":1797},{"className":1796},[],[1798],{"type":35,"value":42},{"type":35,"value":1800}," is often enough. For complex, event-driven, and high-throughput systems, reactive programming shines.",{"type":26,"tag":31,"props":1802,"children":1803},{},[1804],{"type":35,"value":1805},"By mastering both, you’ll be ready to choose the right tool for every concurrency challenge in modern Java applications.",{"type":26,"tag":1807,"props":1808,"children":1810},"h1",{"id":1809},"further-reading",[1811],{"type":35,"value":1812},"Further Reading",{"type":26,"tag":808,"props":1814,"children":1815},{},[1816,1828,1838],{"type":26,"tag":812,"props":1817,"children":1818},{},[1819],{"type":26,"tag":1820,"props":1821,"children":1825},"a",{"href":1822,"rel":1823},"https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html",[1824],"nofollow",[1826],{"type":35,"value":1827},"CompletableFuture Javadoc",{"type":26,"tag":812,"props":1829,"children":1830},{},[1831],{"type":26,"tag":1820,"props":1832,"children":1835},{"href":1833,"rel":1834},"https://projectreactor.io/docs",[1824],[1836],{"type":35,"value":1837},"Project Reactor Documentation",{"type":26,"tag":812,"props":1839,"children":1840},{},[1841],{"type":26,"tag":1820,"props":1842,"children":1845},{"href":1843,"rel":1844},"https://www.reactivemanifesto.org/",[1824],[1846],{"type":35,"value":1847},"Reactive Manifesto",{"type":26,"tag":1849,"props":1850,"children":1851},"style",{},[1852],{"type":35,"value":1853},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}",{"title":8,"searchDepth":106,"depth":106,"links":1855},[1856,1861,1866,1867],{"id":56,"depth":106,"text":59,"children":1857},[1858,1859,1860],{"id":73,"depth":116,"text":76},{"id":487,"depth":116,"text":490},{"id":795,"depth":116,"text":798},{"id":859,"depth":106,"text":862,"children":1862},[1863,1864,1865],{"id":900,"depth":116,"text":903},{"id":1226,"depth":116,"text":1229},{"id":1581,"depth":116,"text":1584},{"id":1640,"depth":106,"text":1643},{"id":1778,"depth":106,"text":1781},"markdown","content:posts:async-java-completable-vs-reactive.md","content","posts/async-java-completable-vs-reactive.md","posts/async-java-completable-vs-reactive","md",1790510064633]