What is the mechanism of ensuring that two threads don't execute portions of a program at the same time?
Responda
Synchronization
Alignment
Hazard-Checking
Paralellization
Questão 2
Questão
Can you pass an integer to a thread as a parameter?
Responda
Yes, but only as an Object. It must be cast inside the thread.
Yes.
No.
No, unless it is a foreground thread.
Questão 3
Questão
What does the [Threadstatic] attribute in a variable entail?
Responda
Each copy of a spawned thread has its own copy of a field.
Each copy of a spawned thread can manipulate the field.
The field can only be modified by one thread at a time.
The field can be modified by the main thread, or any spawned foreground threads.
Questão 4
Questão
How would you add a sequence to a Task?
Responda
.ContinueWith((FirstTask){
//Func
})
.NextTask((FirstTask){
//Func
})
.Continue((FirstTask){
//Func
})
.Then((FirstTask{
//Func
})
Questão 5
Questão
Which are acceptable overloads of the .ContinueWith function?
Responda
TaskContinueationOptions.OnlyCancelled
TaskContinueationOptions.OnlyOnFaulted
TaskContinueationOptions.OnlyRanToCompletion
TaskContinueationOptions.OnlyBlocked
TaskContinueationOptions.OnlyStopped
TaskContinueationOptions.OnlyCompleted
TaskContinueationOptions.OnlyOnCompletion
Questão 6
Questão
What does a task object do?
Responda
Spawn a new thread.
Spawn a new process.
Nothing, it's syntactic sugar
Provides a method of managing thread resources.
Questão 7
Questão
What principles should you keep in mind while creating an asynchronous method?
Responda
Always use await statements.
Avoid returning void.
Be sure to test to ensure a performance increase.
Return a Task or Task<T>
Questão 8
Questão
ConcurrentStacks allow enumeration
Responda
True
False
Questão 9
Questão
You havve a lot of items that need to be processed. For each item, you need to perform complex arithmetic that takes up moderate CPU time. Which technique should you use?
Responda
Create a Task for each item, and wait till all of them are finished
Use a Parallel.For to process all items concurrently
Use Async/Await to process all items concurrently
Add all items to a BlockingCollection and process them on a thread created by the thread class.
Questão 10
Questão
You are creating a complex query that doesn't require any particular order, and you want to run it as parallel. Which method should you use?
Responda
AsParallel
AsSequential
AsOrdered
WithDegreeOfParallelism
Questão 11
Questão
In an ASP.NET project, your application retrieves data from a remote server and writes the response to a database. Should you use the Async/Await keywords for processing?
Responda
Yes, this will free your thread to serve other requests while waiting for a naturally occurring I/O bottleneck.
No, both operations depend on external factors. You must wait before they are finished.
No, in a server application you don't have to use async/await, as the keywords are primarily used in client applications.
Yes, this puts your thread to sleep while waiting for I/O so it uses no CPU time.
Questão 12
Questão
What does the volatile keyword do?
Responda
Ensures that individual copies of a variable are stored in memory
Disables compiler optimizations that assume a single-threaded application
Ensures a variable is never added to a swap file on a disk
Informs the compiler that the variable will be heavily accessed
Questão 13
Questão
Is var++ an atomic operation?
Responda
True
False
Quer criar seus próprios Quizzesgratuitos com a GoConqr? Saiba mais.