Home » Archives for Ashraf Sarhan » Page 3

Author Archives: Ashraf Sarhan

Ashraf Sarhan is a passionate software engineer, an open source enthusiast, has a Bsc. degree in Computer and Information Systems from Alexandria University. He is experienced in building large, scalable and distributed enterprise applications/service in multiple domains. He also has a keen interest in JavaEE, SOA, Agile and Big Data technologies.

java.util.concurrent.ThreadLocalRandom Example

In this example we shall show you how to make use of ThreadLocalRandom class, ThreadLocalRandom is a random number generator like its parent Random class. Like the global Random generator class, a ThreadLocalRandom is initialized with an internally generated seed that may not otherwise be modified.         1. ThreadLocalRandom Advantages ThreadLocalRandom provide more good performance and less overhead in ...

Read More »

java.util.concurrent.FutureTask Example

In this example we shall show you how to make FutureTask, FutureTask is an implementation of Future which offers a very elegant way to implement parallel execution of tasks in Java where a big task can be split into small chunks and if each of those chunks can be executed in parallel, it can result in better response times and throughput. We can ...

Read More »

com.sun.net.httpserver.Filter Example

In this example we shall show you how to make use of Filter class, A Filter is mainly used for pre or post processing of the incoming requests such as: Examine or modify the request headers. Set attribute Objects in the exchange using setAttribute(String name, Object value), which other filters or the exchange handler can access. Invoke the next filter in the chain, ...

Read More »

com.sun.net.httpserver.HttpServer Example

In this example we shall show you how to make use of HttpServer class, This class implements a simple HTTP server where we can start an embedded HTTP server which is bound to an IP address and port number and listens for incoming TCP connections from clients on this address. To process the incoming requests, we have to implement one ...

Read More »

TestNG Configuration Annotations Example

In this example we shall show you the TestNG Configuration Annotations. TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing (testing a class in isolation of the others) to integration testing (testing entire systems made of several classes, several packages and even several external frameworks, such as application servers). Annotations is one ...

Read More »

Dynamic Class Loading Example

In this example we shall show you Java Dynamic Class Loading, Dynamic Java Class loading is an important mechanism which provides the Java platform with the ability to install software components at run-time where you can load your classes in a lazy loading manner which means that classes are loaded on demand and at the last moment possible. Dynamic Java ...

Read More »

Java Daemon Thread Example

In this example we shall show you how to make use Java Daemon Thread, A Thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads (User, Daemon) of execution running concurrently. A Daemon Thread is typically used to provide a general service in the background as long as the program is running ...

Read More »

Write/Read CSV Files with Apache Commons CSV Example

In this example we will continue to demonstrate how to Write/Read CSV (Comma Separated Values) files in java. In our previous example, we already show how to do that using a native Java code. However, this example will illustrate how to write and read CSV files with an open source 3rd Party tool “Apache Commons CSV”, Apache Commons CSV library ...

Read More »

Write/Read CSV Files in Java Example

In this example we are going to demonstrate how to Write/Read CSV files. CSV (Comma Separated Values) is a file format for data storage which looks like a text file, contains information which is organized with one record on each line and each field is separated by comma. A CSV file is primarily used in database migration process where we ...

Read More »

java.util.concurrent.DelayQueue Example

In this example we shall show you how to make use of DelayQueue class. DelayQueue is an unbounded time-based scheduling BlockingQueue of Delayed elements backed by a heap where an element can only be taken when its delay has expired. If multiple elements have expired delays, the element with the longest delay expiration will be taken first.       DelayQueue characteristics: DelayQueue is ...

Read More »