java synchronized on object, class and block

synchronized Blocks do have advantages over methods, most of all in flexibility because you can use other object as lock whereas syncing the method would lock the complete class. Compare: // locks the whole object … private synchronized void someInputRelatedWork() { … } private synchronized void someOutputRelatedWork() { … } Vs. // Using specific locks…

object vs closure

Consider this JavaScript function: 1 2 3 4 5 function fn() { var a = 10; var b = { name: ‘foo’, n: 10 }; } This might produce the following: I say “might” because specific behaviors depend heavily on implementation. This post takes a V8-centric approach with many diagram shapes linking to relevant source…

angularjs scope inheritence primitive object

JavaScript Prototypal Inheritance It is important to first have a solid understanding of JavaScript prototypal inheritance, especially if you are coming from a server-side background and you are more familiar with classical inheritance. So let’s review that first. Suppose parentScope has properties aString, aNumber, anArray, anObject, and aFunction. If childScope prototypically inherits from parentScope, we…

convert string to json object

In JS To convert a JSON text into an object, you can use the eval() function. eval() invokes the JavaScript compiler. Since JSON is a proper subset of JavaScript, the compiler will correctly parse the text and produce an object structure. The text must be wrapped in parens to avoid tripping on an ambiguity in…

java OOP basic vocabularies

What is a Class? Class is a template for a set of objects that share a common structure and a common behavior. What is an Object? Object is an instance of a class. It has state,behaviour and identity. It is also called as an instance of a class. What are the core OOP’s concepts? Abstraction, Encapsulation,Inheritance…