[Java] - Effects of not using the "volatile" declaration in | SheCodes

[Java] - Effects of not using the "volatile" declaration in a Java program for multithreading

Observing the effects of not using the "volatile" declaration in a Java program when executing across multiple threads and identifying the input value that causes the program to hang

👩‍💻 Technical question

Run the Java program per the instructions in the "Peachy Assignments" description by having (and commenting out) the volatile declaration of the Req and Ack variables. This can make the execution effects of Req and Acq becoming vvisible across threads different (e.g. compilers can rearrange Req to be after Ack, as they are two independent and unrelated variables). Observe when the run without volatiles hangs (what input value did you supply)? Provide two answers: * The input number that seemed to hang the execution 50% of the time or more Write a 300-character (roughly) description of the purpose of this test and what you observed. The notion of "happens before" is mentioned in my "Peachy Assignments". It basically says that if two instructions A and B come in a certain order, their executions must appear to be in that order also. This is achieved by slapping the "volatile" variable annotation.

More coding questions about Java

👩‍💻 Technical question

how to use if else in java?

👩‍💻 Technical question

Asked 1 year ago in Java by Miguel

the multiplicate operator isnt working in my Java code, how can I fix it?

👩‍💻 Technical question

class overload { int x; int y; void add(int a) { x = a + 1; } void add(int a, int b) { x = a + 2; } } class Overload_methods { public static void main(String args[]) { overload obj = new overload(); int a = 0; obj.add(6); System.out.println(obj.x); } }

👩‍💻 Java Code instructions

Using MVC, servlets, jsps and java maven how would i implement Intended redirects for logged in users. I already have a project using adlister I need to add this to it. using java maven

👩‍💻 Technical question

How do I use public Grade(String grade) in a code correctly

👩‍💻 Technical question

What is a String in Java

👩‍💻 Technical question

What does argument mean in Java?

👩‍💻 Technical question

String to Long java

👩‍💻 Java Code instructions

write a code to print the palindrome

👩‍💻 Java Code instructions

Write an algorithm with its corresponding code implementation in Java for Euclid's method of finding the GCD and the sieve of Eratosthenes.

👩‍💻 Technical question

how to install java

👩‍💻 Java Code instructions

Asked over 1 year ago in Java by Katherine

Find fibonacci number example : fibo of 0 = 1 fibo of 1 = 1 fibo of 2 = fibo 0 + fibo 1 = 2 fibo of 3 = fibo 2 + fibo 1 = 3 fibo of 4 = fibo 3 + fibo 2 = 5 fibo of 5 = fibo 4 + fibo 3 = 8 write function int fibo(int number) -> return fibo value of paramerter. write code with possible small time complexity

👩‍💻 Java Code instructions

Asked over 1 year ago in Java by Christina Ashley

Can you create a login and registration code for my java application?

👩‍💻 Technical question

Why is my else statement not working in java

👩‍💻 Technical question

can you show to example of the java function?

👩‍💻 Technical question

What is java?

👩‍💻 Java Code instructions

For this method you will be given a numerator and a denominator and return true if they are reduced and false if not. public static boolean reduced (int num, int denom)

👩‍💻 Java Code instructions

finally your friend needs a method to check if one of the players has won. This determines if either color has 0% remaining pieces. if one color has one you will return that color if no one has won you will return "NONE". public String hasWon (char[][] board)

👩‍💻 Technical question

how to check if a string is bigger in length than the other in java

👩‍💻 Technical question

how to write a code with java that asks two addition math questions using random variables

👩‍💻 Technical question

Asked almost 2 years ago in Java by redsbloxmen

What is Java?

👩‍💻 Technical question

How do i create a loop function in Java using an array of cities?

👩‍💻 Technical question

whats the code for java alert message

👩‍💻 Technical question

is "body" a class

👩‍💻 Technical question

how to write an array?

👩‍💻 Technical question

format the date time

👩‍💻 Technical question

would you explain polymorphism?

👩‍💻 Technical question

what is java?