0% found this document useful (0 votes)
4 views10 pages

Assignment No.2 Java

The document discusses various aspects of thread management in programming, including thread states such as runnable, blocked, waiting, and terminated. It also covers synchronization techniques to prevent inconsistencies when multiple threads access shared resources, as well as exception handling in Java. Additionally, it highlights the differences between checked and unchecked exceptions.

Uploaded by

gopalecyber
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Assignment No.2 Java

The document discusses various aspects of thread management in programming, including thread states such as runnable, blocked, waiting, and terminated. It also covers synchronization techniques to prevent inconsistencies when multiple threads access shared resources, as well as exception handling in Java. Additionally, it highlights the differences between checked and unchecked exceptions.

Uploaded by

gopalecyber
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
E + AssigAMeny No.2. Dees aca a 7[ereinained JR le sath Eale-dpea +25 thread lite (eles mt vn a —T tut Thread L News J —slereninnis beeen nid meee — { ssartca eee ee E [—aiemgble FSS L ; roo | “Pyend o o =) pead] _ ime | é “a ie 3 at | ; Running} Cas he po te ay a oe sree gatity : sagt LT piocked i 502 Ties Thyends: iat ae ge & thvead io Saud iyeiconly passes thyaugh the | fatleusing states defines the ‘Thread State eoum + iA liveodl ts In this State’ when. ir ts. Created : but not syeh | i thread _€ = new Thread cd i iS Mo System rescunce’ ave allaccted yeh. Runnable ==! - i Act: calling Stortc).tho _thyead enters_dhe _vunriable fake. of a Ti Tk ts Yeady to xan and wolring for ‘cea i Exumple- oe E Stavk C2 @ scanned with OKEN Scanner _-3.._ Blocked = i) the Ihvead ts. Aid Happens vuhen block / melbocl. waiting do equiva. fo} Lack hying do enlea a Synthya nize." 4 _vaaiting~ ___i\_the thyeael “anil tndeCinifely_unki| Onathey ven Signals id = ii) Comman methods: ci i) wait 2) doin a S}__ Timed= waiting - i\ the thread” cocits Pap O_Specitie Periac| i_methacls ly Sleea Cdime) + 25 walt Cdimeé). ) Jain C time) 6) _* Terminated _( decid ) 3) The thread has Completed. exacin.c8 ied ny It Cannot be ‘eshuree! | mae exception - (user ctinst =). lniport —laue Uhl sane. > @ scanned with OKEN Scanner Ee class. Agecheck— ain =} . ha ak Ed sieten anor ‘CS Enter. your_ay eis A i See Aa ee i€ Cage fisss Buimetthvesid_extend.s thread 7 | Buhl Uaicl_yun_cd t ee Gob" psi |¢=Soa nite Va a Cis Prime cid 3 System-autpriatlo Ci) 2 [Link]. pyintin c thread intervue WS 3) - 1 ; ee Prim@numbers thread ema prime Thread E = new Prime Thread ¢y i [Link] eo: @ scanned with OKEN Scanner ——— i IL === ee wuvite “A davel_Pragrom_to_clemansivake how_to ~ “| creale_user-_defined excephian te MyException extends _ExceP-ia0————__ pesca ten. essay] —— cr H Shak Cmesge Ls : = : public class main oS < | int age = [6 [ey | i une . le Case 18) | hyout new My exception C“ Age must he 8 ax above.) s gise_ eae i 7 Sistem suk pant CEIgibED; L | Culsh Cry Exceptian ©). ee System -aur. prin C“\ Exceptian tp | 3 @.[Link]): 3 th ATE ne @ scanned with OKEN Scanner mnueh {ou] foot “qr “usvite_cl_daua pyogvam do_imelement. “orpray lish __with function da ddd. vemove f Sark _membex, “> impavtdawe-ubi. “Roary list 3 _—imPort saua-ukib, callections:: —_public—class. —avryiSA2semn le Sid man aha Bag) aa ana: ag Qe 0 ne aaa Ge + ities Ida ‘acid CH Apple 1): | iste adel © oe ! — Sena nb tn eats.) l 2 Cotlechianswstyt C fist ds 3 8d ue | system aut -printin Cvaeter Savting * ne | 5 System. Auth fxantin Qi fa Tint ad G2. iefeventiate bohween checked aid unchecked | excephian @ scanned with OKEN Scanner Rosie] g meFioatian| in§|_ Compile = dime ____— _checked Exception Exception [Link] the Compiler:_at compile time: ~ unchecked Exception exception thet k id ¢cuy. |-cliuring runtime - hry catch ox throws“ 2 | External Cone Hons CFile 4 Pesan enishacks MISSing date bose eran, Nelo issue. —__| Clogre ‘eivavt) aut lang. exces Jounta 0: Rushime Bycep fiat ifnot fannie 5 ompiles bus omy. crash “ak yundine ‘. i &icephian - * used aheN eco is ‘asad for buss thu ~Seenavin_| Possible haut a Ae Nutieatat ExcepHan ete: Eo 4 @ scanned with OKEN Scanner

You might also like