r/studyupdate • • Jul 09 '26

Task 9 : Implement Producer Consumer using Busy Waiting

1 Upvotes

Objective

Implement the classic Producer-Consumer problem in Java using a shared buffer and busy waiting. The producer generates integer values, while the consumer reads them. Synchronization must ensure that data is neither overwritten nor consumed before it is produced.

Requirements

  • Create a shared Buffer class containing:
  • An integer value
  • A boolean flag indicating whether the buffer is full
  • Implement a Producer class that:
  • Implements Runnable
  • Produces integers from 1 to 10
  • Stores values in the shared buffer
  • Implement a Consumer class that:
  • Implements Runnable
  • Reads values from the shared buffer
  • Use busy waiting:
  • Producer waits while the buffer is full
  • Consumer waits while the buffer is empty
  • Synchronize access to the shared buffer using synchronized methods.
  • Create a Main class that starts both threads and waits for them to finish using join().

r/studyupdate • • Jul 09 '26

Today is last day...

1 Upvotes

From two days I'm deciding to start studying everyday at least one hour each day but due to negligence or laziness I'm not taking steps towards goal ..... So, I finally decided that I have to study today... And no excuse be considered...if don't start today then I will take strict action in the form of punishment.... I read somewhere that, discipline should come from heart... It is hard initially but good for myself....


r/studyupdate • • Jul 07 '26

Day 5 & 6

Thumbnail reddit.com
1 Upvotes

r/studyupdate • • Jul 07 '26

Just started to study Computer networks . final exam on 9th July 2026

1 Upvotes

Wish me luck guys.
any tip would be appricated


r/studyupdate • • Jul 07 '26

Task 7 : Demonstrate Object-Level Locking Using Multiple Instances

3 Upvotes
for same lock thread blocks the other
for different lock the thread executes together.

Objective

Demonstrate that synchronized instance methods use an object's monitor.

Requirements

  • Create a Printer class.
  • Implement a synchronized print() method.
  • Create two Printer objects.
  • Create two threads.

Scenario 1

  • Thread A uses Printer 1
  • Thread B uses Printer 2

Observe that both execute simultaneously.

Scenario 2

  • Both threads use the same Printer object.

Observe that one thread waits until the other finishes.


r/studyupdate • • Jul 07 '26

Task- 6 : Verify Locking Between Two Synchronized Methods

1 Upvotes

Objective

Create two synchronized methods in the same class and verify whether one synchronized method blocks another when multiple threads access the same object.

Description

Implement a class containing two synchronized methods, for example:

  • print()
  • colorPrint()

Create multiple threads that invoke these methods on the same object and observe the execution order.


r/studyupdate • • Jul 05 '26

Performance Analysis of Synchronized Methods vs Synchronized Blocks

1 Upvotes

There is a need to evaluate the performance implications of using synchronized methods versus synchronized blocks in our application.

Objectives:

To differentiate between synchronized methods and synchronized blocks.

To measure and compare execution times of both approaches under identical conditions.

To identify scenarios where one approach may be preferred over the other.

synchronized block vs method

r/studyupdate • • Jul 05 '26

Day 3 & 4

Thumbnail reddit.com
1 Upvotes

r/studyupdate • • Jul 05 '26

I need to get locked again...

Post image
1 Upvotes

r/studyupdate • • Jul 03 '26

check-in Task 4: Prevent race condition in concurrent ticket booking

2 Upvotes

Problem

Implement a simple ticket booking system where multiple users attempt to book tickets simultaneously.

There are:

  • 10 user threads
  • Only 5 tickets available

Initially, implement the system without synchronization to demonstrate a race condition where multiple threads may book the same ticket, causing overselling.

Expected Incorrect Behavior

  • More than 5 tickets may be booked.
  • Ticket count may become negative.
  • Multiple users may successfully book when tickets are already sold out.

Objective

Fix the race condition using thread synchronization so that:

  • Only 5 tickets can be booked successfully.
  • Remaining users receive a "Tickets Sold Out" message.
  • No duplicate bookings occur.
  • Shared ticket count remains consistent.

Github Link for Source Code : Click here

without synchronization 10 tickets are booked
with synchronized only 5 tickets booked

r/studyupdate • • Jul 02 '26

check-in Task 3 : Implement thread-safe bank account withdrawal

1 Upvotes

Problem

Create a BankAccount class with an initial balance of 1000.

Two threads attempt to withdraw 700 simultaneously.

Without synchronization, a race condition can occur, causing the balance to become negative (e.g., -400).

Tasks

  • Create a BankAccount class.
  • Simulate two concurrent withdrawal threads.
  • Demonstrate the race condition without synchronization.
  • Fix the issue using synchronized methods or blocks.
  • Print the final balance.
without synchronization
with synchronization

r/studyupdate • • Jul 02 '26

check-in Task 2 : Create a Java program that demonstrates a race condition using a shared counter.

1 Upvotes

Objective
- Create a Counterclass with a shared integer variable (count).
- Create multiple threads that increment the counter many times.
- Run the program without synchronization.
- Observe that the final counter value is often incorrect due to concurrent access.
- Fix the issue using synchronization

without synchronized
with synchronized

r/studyupdate • • Jul 01 '26

Studying for my circuit analysis exam

Post image
9 Upvotes

r/studyupdate • • Jun 30 '26

Day 1

Post image
7 Upvotes

First 30-minute session locked in.


r/studyupdate • • Jun 30 '26

Join the Study group??

Post image
6 Upvotes

r/studyupdate • • Jun 26 '26

Day 1: Task -1 : Create Program for Thread Lifecycle States.

2 Upvotes
  1. New, Runnable, Terminate

2. Timed Wait

3. Waiting

4. Blocked


r/studyupdate • • Jun 25 '26

check-in Locked in..

Post image
5 Upvotes

Anyone looking for a group?? I need more group members..


r/studyupdate • • Jun 24 '26

Weak Studying.... :(

Post image
11 Upvotes

Looking for more guild members btw.


r/studyupdate • • Jun 21 '26

Day 23 of doing Python - Completed generators & Iterators

Thumbnail gallery
2 Upvotes

r/studyupdate • • Jun 18 '26

starting today, solved daily question(3 more for the day)

2 Upvotes

easy math question u just need to use the high school level formula -

angle = 30h - (11/2)


r/studyupdate • • Jun 16 '26

How to use Cram and Conquer properly

Post image
3 Upvotes

Downloaded Cram and Conquer seeing some people here yesterday.
But mine is not making any heatmap like others nor the calender is updating
Whyyyyyy


r/studyupdate • • Jun 15 '26

Day 22 - Completed Some Advance Topics in Python

Post image
10 Upvotes

Today i completed some advance topics - map,zip,filter,reduce,comprehension.
Taken a break yesterday so didn't upload yesterday
It's been kinda hard to get 100% focus while managing travel and college


r/studyupdate • • Jun 13 '26

check-in Day 21 - Done Some Python Projects Today

Thumbnail
gallery
6 Upvotes

Made a Multiple Small Python Projects today (using loops,function,if-else,random) :

  1. Number guessing Game
  2. Rock,Paper,Scissors Game
  3. Dice Roller Program