Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
1b)Explain why class Q4 below is not thread safe. Re-write it to make it thread safe. class Q4{ private boolean f[] = new boolean[20]; public
1b)Explain why class Q4 below is not thread safe. Re-write it to make it thread safe.
class Q4{
private boolean f[] = new boolean[20];
public Q4(){ for(int j = 0; j < 20; j++) f[j] = true;}
public void negate(int a, int b){ for(int j = a; j < b; j++)f[j] = !f[j]; }
public void swap(int a, int b){ boolean temp = f[a]; f[a] = f[b]; f[b] = temp; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started