Ways to utilise java thread to perform concurrent execution
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
".
精彩评论