
Concurrency
Authored by Jose Diaz
Computers
1st Grade
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
9 questions
Show all answers
1.
MULTIPLE SELECT QUESTION
3 mins • 1 pt
Which of the following options correctly create an ExecutorService instance?. Please select 2 options.
var es = ExecutorService.getInstance();
var es = new ExecutorService();
var es = Executors.newFixedThreadPool(2);
var es = Executor.getSingleThreadExecutor();
var es = Executors.newVirtualThreadPerTaskExecutor();
2.
MULTIPLE SELECT QUESTION
3 mins • 1 pt
Which of the following code fragments will you use to create an ExecutorService?. Please select 3 options.
ExecutorService
Executor
Executors
.newSingleThreadExecutor();
.newVirtualThreadPerTaskExecutor();
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following statements correctly create a virtual thread? (Assume that r refers to a Runnable instance.). Please select 1 option.
Thread t = new VirtualThread(r);
Thread t = new VirtualThread(r);
VirtualThread t = Thread.ofVirtual();
Thread t = Thread.ofVirtual();
Thread t = Thread.ofVirtual().unstarted(r);
4.
MULTIPLE SELECT QUESTION
3 mins • 1 pt
Given:
ReadWriteLock rl = new ReentrantReadWriteLock();
Lock rlock = rl.readLock();
Lock wlock = rl.writeLock();
Identify correct statements regarding code that appears after the above code. (Consider each option individually.). Please select 3 options.
rlock.lock();
System.out.println("read lock acquired");
wlock.lock();
System.out.println("write lock acquired");
This code will print both the statements.
wlock.lock();
System.out.println("write lock acquired");
rlock.lock();
System.out.println("read lock acquired");
This code will print both the statements.
rlock.lock();
System.out.println("read lock acquired");
rlock.lock();
System.out.println("read lock acquired again");
This code will print both the statements.
rlock.lock();
rlock.lock();
rlock.unlock();
wlock.lock();
System.out.println("write lock acquired");
This code will print the statement.
rlock.lock();
try{
wlock.tryLock();
wlock.unlock();
System.out.println("write lock acquired ");
}catch(Exception e) {
e.printStackTrace();
}
This code will print an exception stack trace.
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
You have a collection (say, an ArrayList) which is read by multiple reader threads and which is modified by a single writer thread. The collection allows multiple concurrent reads but does not tolerate concurrent read and write. Which of the following strategies will you use to obtain best performance?. Please select 1 option.
synchronize all access to the collection.
make the collection variable final.
make the collection variable final and volatile.
Wrap the collection into its synchronized version using Collections.synchronizedCollection().
Encapsulate the collection into another class and use ReadWriteLock to manage read and write access
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
What will the following code print?
AtomicInteger ai = new AtomicInteger();
Stream<Integer> stream = Stream.of(11, 11, 22, 33).parallel();
stream.filter(
e->{ ai.incrementAndGet();
return e%2==0;
});
System.out.println(ai); Please select 1 option.
0
Any number between 1 to 4.
4
Any number between 0 to 3
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
If a synchronized method ends up throwing an exception to the caller, the lock acquired by the thread associated with this method due to the usage of the synchronized keyword is released automatically. Please select 1 option.
true
false
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
12 questions
Petlje u pythonu
Quiz
•
1st - 5th Grade
10 questions
keys and keyboard
Quiz
•
1st Grade
10 questions
Uas TIK Kelas 10
Quiz
•
1st Grade
10 questions
Программирование алгоритма 8 класс
Quiz
•
1st - 10th Grade
14 questions
Malware And Hackers
Quiz
•
KG - University
10 questions
Shortcut keys
Quiz
•
1st - 2nd Grade
10 questions
Latihan Soal Ms Word
Quiz
•
1st - 12th Grade
10 questions
PRE TEST - Webinar Edukasi 11 June 22
Quiz
•
1st - 3rd Grade
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
Discover more resources for Computers
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
10 questions
Christmas/Winter
Quiz
•
KG - 2nd Grade
20 questions
Christmas Movies
Quiz
•
1st - 12th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
1st - 3rd Grade
10 questions
Christmas Characters
Quiz
•
KG - 3rd Grade
10 questions
Exploring Christmas Math Word Problems
Interactive video
•
1st - 5th Grade
16 questions
Christmas 1st grade
Quiz
•
1st Grade