Skip to content

Instantly share code, notes, and snippets.

Avatar

raghu bhupatiraju raghuvarmabh

View GitHub Profile
View set name
public static void main(String[] args) {
Person person = new Person("Tom Criuse", 44);
modifyPerson(person);
System.out.println(person.getName());
}
private static void modifyPerson(Person person) {
person.setName("Brad Pit");
View part1
public class ReferenceTest {
public static void main(String[] args) {
Person person = new Person("Tom Criuse", 44);
System.out.println(person.getName());
}
}
View person.java
public class Person {
private String name;
private int age;
Person(String name, int age){
this.name = name;
this.age = age;
}
public String getName() {
View synchroized_with_different_object.java
class TicketCounter extends Thread {
TicketingSystem ticketingSystem;
public TicketCounter(String name) {
this.setName(name);
start();
}
@Override
public void run() {
View Ticketing_system_with_synchronized_method.java
class TicketingSystem {
static final Ticket number1 = new Ticket("Number1", "open");
static final Ticket number2 = new Ticket("Number2", "open");
static Ticket[] numberList = new Ticket[] {number1, number2};
public static synchronized String getNextAvailableTicket() {
String availableNumber = null;
try {
View synchronized_block.java
public static String getNextAvailableTicket() {
String availableNumber = null;
try {
synchronized(TicketingSystem.class){
for (Ticket number: numberList) {
if(number.getStatus() == "open") {
number.setStatus("pending"); // changing the state of the object
System.out.printf("Thread name %s - number found %s \n",Thread.currentThread().getName(), number.getName());
View Ticketing_system_without_synchronization.java
class Ticket {
private String name;
private String status;
public Ticket(String name, String status) {
this.name = name;
this.status = status;
}
@raghuvarmabh
raghuvarmabh / gist:9a68edddbd78f37fc9f5dfed9d2ad711
Last active Aug 8, 2019
Multi Threading synchronization example
View gist:9a68edddbd78f37fc9f5dfed9d2ad711
import java.util.Arrays;
public class SyncExample {
public static void main(String[] args) {
try {
TicketingSystem ts = new TicketingSystem();
TicketCounter tc1 = new TicketCounter(ts, "Thread 1");
TicketCounter tc2 = new TicketCounter(ts, "Thread 2");
View alex coding challenge.patch
diff --git a/app/models/provider.rb b/app/models/provider.rb
index c468731..d4afb3a 100644
--- a/app/models/provider.rb
+++ b/app/models/provider.rb
@@ -1,3 +1,4 @@
class Provider < ApplicationRecord
has_many :customers, as: :company
+ has_many :tracking_events
end
diff --git a/app/models/shipper.rb b/app/models/shipper.rb
View erik coding challenge.patch
From 43bbfa63f3efa6b10abcd7454d2953cb37b9efc9 Mon Sep 17 00:00:00 2001
From: Raghu <raghuvarma.bhr@gmail.com>
Date: Mon, 15 Oct 2018 15:34:18 -0700
Subject: [PATCH 1/2] Code challenge
---
vue-spa/src/App.vue | 14 ++++++++++++--
vue-spa/src/components/TrackableEvent.vue | 17 +++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 vue-spa/src/components/TrackableEvent.vue