Anvi Jain has Published 569 Articles

pthread_cancel() in C

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

723 Views

The threa_cancel() is used to cancel one particular thread by the thread id. This function sends one cancellation request to the thread for termination. The syntax of the pthread_cancel() is like below −int pthread_cancel(pthread_t th);Now, let us see how to cancel threads using this function.Example#include #include #include ... Read More

How to use Notification Inbox style in Android

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

361 Views

This example demonstrate about How to use Notification Inbox style in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 ... Read More

Performing distinct on multiple fields in MongoDB?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

2K+ Views

You can use $group operator along with aggregate framework to perform distinct on multiple fields. Let us first create a collection with documents −> db.distinctOnMultipleFieldsDemo.insertOne( ...    { ...       "StudentFirstName" : "Chris", ...       "StudentAge" : 21, ...       "StudentCountryName": "US" ...   ... Read More

How to store MongoDB result in an array?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

1K+ Views

To store MongoDB result in an array, use the toArray() method −var anyVariableName=db.yourCollectionName.find().toArray();Let us first create a collection with documents −> db.mongoDbResultInArrayDemo.insertOne({"CustomerName":"David Miller", "CustomerAge":24, "isMarried":false}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd99bd5b50a6c6dd317ad92") } > db.mongoDbResultInArrayDemo.insertOne({"CustomerName":"Sam Williams", "CustomerAge":46, "isMarried":true}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd99beab50a6c6dd317ad93") } ... Read More

How to display tree structured data in Java?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

808 Views

To display tree structured data, use the JTree control in Java Swing.At first, create a node in the tree −DefaultMutableTreeNode node = new DefaultMutableTreeNode("Project");Now, add nodes to the node created above −DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("App"); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Website"); DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("WebApp"); node.add(node1); node.add(node2); node.add(node3);Now, create ... Read More

Difference between fork() and exec() in C

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

4K+ Views

Here we will see the effect of fork() and exec() system call in C. The fork is used to create a new process by duplicating the calling process. The new process is the child process. See the following property.The child process has its own unique process id.The parent process id ... Read More

Implement MongoDB toLowerCase() in a forEach loop to update the name of students?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

175 Views

Let us first create a collection with documents wherein one of the fields is StudentName −> db.lowerCaseDemo.insertOne({"StudentName":"JOHN SMith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd9a86fb50a6c6dd317ad9f") } > db.lowerCaseDemo.insertOne({"StudentName":"CAROL TAYLor"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd9a88fb50a6c6dd317ada0") } > db.lowerCaseDemo.insertOne({"StudentName":"DAVID Miller"}); {    "acknowledged" : true,   ... Read More

How to show an android notification exactly 3 actions?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

227 Views

This example demonstrate about How to determine if an activity has been called by a Notification in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to ... Read More

MongoDB Query to combine AND & OR?

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

2K+ Views

To combine AND & OR in MongoDB, let us first create a collection with documents −>db.combinedAndOrDemo.insertOne({"StudentFirstName":"John", "StudentAge":23, "StudentSkill":"MongoDB"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd306dcb64f4b851c3a13e2") } >db.combinedAndOrDemo.insertOne({"StudentFirstName":"Larry", "StudentAge":21, "StudentSkill":"MySQL"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd306f3b64f4b851c3a13e3") } >db.combinedAndOrDemo.insertOne({"StudentFirstName":"Sam", "StudentAge":24, "StudentSkill":"SQL Server"}); {    "acknowledged" : true, ... Read More

Linear search using Multi-threading in C

Anvi Jain

Anvi Jain

Updated on 30-Jul-2019 22:30:26

910 Views

Here we will see how to apply the multi-threading concept to search one element in an array. Here the approach is very simple. We will create some threads, then divide the array into different parts. Different thread will search in different parts. After that, when the element is found, enable ... Read More

Advertisements