开发者

Ways to utilise java thread to perform concurrent execution

开发者 https://www.devze.com 2023-04-06 16:52 出处:网络
During the exam I had following question: \"What is a Java thread and how are multiple threads handled by a single

During the exam I had following question: "What is a Java thread and how are multiple threads handled by a single processor core? [2 marks]

(a) Describe the two ways in which a class may utilise a thread to perform concurrent execution. [6 marks]

(b) How does Java’s synchronized keyword help with concurre开发者_StackOverflow中文版nt thread execution? [2 marks]"

Could anyone make a respond to point a? I wrote that by calling this thread's start() method and by passing this thread to executor? Is it correct?


Since it looks like beginner stuff, I would probably go with "subclassing Thread" and "implementing Runnable and passing that to a Thread".

0

精彩评论

暂无评论...
验证码 换一张
取 消