Tutorial by Examples: is

As we know that we should use synchronized keyword to make execution of a method or block exclusive. But few of us may not be aware of one more important aspect of using synchronized and volatile keyword: apart from making a unit of code atomic, it also provides read / write barrier. What is this re...
private static void explicitTaskParallism() { Thread.CurrentThread.Name = "Main"; // Create a task and supply a user delegate by using a lambda expression. Task taskA = new Task(() => Console.WriteLine($"Hello from task {nameof(taskA)}.")...
private static void Main(string[] args) { var a = new A(); var b = new B(); //implicit task parallelism Parallel.Invoke( () => a.DoSomeWork(), () => b.DoSomeOtherWork() ); }
This example assumes that you have experience in creating Rails applications. To create an API-only app in Rails 5, run rails new name-of-app --api Add active_model_serializers in Gemfile gem 'active_model_serializers' install bundle in terminal bundle install Set the ActiveModelSeriali...
Realm currently does not support storing a list of primitives. It is on their todo list (GitHub issue #575), but for the meantime, here is a workaround. Create a new class for your primitive type, this uses Integer, but change it for whatever you want to store. public class RealmInteger extends Re...
Calling the dependencies task allows you to see the dependencies of the root project: gradle dependencies The results are dependency graphs (taking into account transitive dependencies), broken down by configuration. To restrict the displayed configurations, you can pass the --configuration opti...
When using prompt a user can always click Cancel and no value will be returned. To prevent empty values and make it more persistent: <h2>Welcome <span id="name"></span>!</h2> <script> // Persistent Prompt modal var userName; while(!userName) { userN...
The code below will prompt for numbers and continue to add them to the beginning of a linked list. /* This program will demonstrate inserting a node at the beginning of a linked list */ #include <stdio.h> #include <stdlib.h> struct Node { int data; struct Node* next; }; ...
PHP only allows single inheritance. In other words, a class can only extend one other class. But what if you need to include something that doesn't belong in the parent class? Prior to PHP 5.4 you would have to get creative, but in 5.4 Traits were introduced. Traits allow you to basically "copy...
Using vanilla mathematics: var from:Point = new Point(300, 10); var to:Point = new Point(75, 40); var a:Number = to.x - from.x; var b:Number = to.y - from.y; var distance:Number = Math.sqrt(a * a + b * b); Using inbuilt functionality of Point: var distance:Number = to.subtract(from).len...
You can test whether a point is inside a rectangle using Rectangle.containsPoint(): var point:Point = new Point(5, 5); var rectangle:Rectangle = new Rectangle(0, 0, 10, 10); var contains:Boolean = rectangle.containsPoint(point); // true
In addition to predicates functioning as specs, you can register a spec globally using clojure.spec/def. def requires that a spec being registered is named by a namespace-qualified keyword: (clojure.spec/def ::odd-nums odd?) ;;=> :user/odd-nums (clojure.spec/valid? ::odd-nums 1) ;;=> tru...
A While loop starts by evaluating a condition. If it is true, the body of the loop is executed. After the body of the loop is executed, the While condition is evaluated again to determine whether to re-execute the body. Dim iteration As Integer = 1 While iteration <= 10 Console.Writeline(ite...
Any time you instantiate a class that Implements IDisposable, you should call .Dispose1 on that class when you have finished using it. This allows the class to clean up any managed or unmanaged dependencies that it may be using. Not doing this could cause a memory leak. The Using keyword ensures th...
Make sure your image object is fully loaded before you try to draw it on the canvas with context.drawImage. Otherwise the image will silently fail to display. In JavaScript, images are not loaded immediately. Instead, images are loaded asynchronously and during the time they take to load JavaScript...
The obvious way to zero a register is to MOV in a 0—for example: B8 00 00 00 00 MOV eax, 0 Notice that this is a 5-byte instruction. If you are willing to clobber the flags (MOV never affects the flags), you can use the XOR instruction to bitwise-XOR the register with itself: 33 C0 ...
Background If the Carry (C) flag holds a value that you want to put into a register, the naïve way is to do something like this: mov al, 1 jc NotZero mov al, 0 NotZero: Use 'sbb' A more direct way, avoiding the jump, is to use "Subtract with Borrow": sbb al,a...
Background To find out if a register holds a zero, the naïve technique is to do this: cmp eax, 0 But if you look at the opcode for this, you get this: 83 F8 00 cmp eax, 0 Use test test eax, eax ; Equal to zero? Examine the opcode you get: 85 c0 test ea...
This example will show you how to create a Windows Forms Application project in Visual Studio. Create Windows Forms Project Start Visual Studio. On the File menu, point to New, and then select Project. The New Project dialog box appears. In the Installed Templates pane, select "...
docker network ls This command lists all networks that have been created on the local Docker host. It includes the default bridge bridge network, the host host network, and the null null network. All containers by default are attached to the default bridge bridge network.

Page 35 of 109