<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Learnxpress &#187; multithreading</title>
	<atom:link href="http://www.learnxpress.com/tags/multithreading/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learnxpress.com</link>
	<description>Your Learning Encyclopedia</description>
	<lastBuildDate>Mon, 06 Sep 2010 04:49:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>A comparison between Java and C#</title>
		<link>http://www.learnxpress.com/a-comparison-between-java-and-c.html</link>
		<comments>http://www.learnxpress.com/a-comparison-between-java-and-c.html#comments</comments>
		<pubDate>Mon, 09 Feb 2009 05:34:40 +0000</pubDate>
		<dc:creator>Anand Narayanaswamy</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[briefly about c# and c# tools]]></category>
		<category><![CDATA[c sharp compiler download]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[c# compilers]]></category>
		<category><![CDATA[C# keywords classified]]></category>
		<category><![CDATA[develop in c# in windows98]]></category>
		<category><![CDATA[download C# compiler for windows xp]]></category>
		<category><![CDATA[download different Types Of Compilers in C#]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[explain briefly about c# and c# tools]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java applets]]></category>
		<category><![CDATA[multiform application in C#.Net]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://www.learnxpress.com/en/2009/02/09/a-comparison-between-java-and-c/</guid>
		<description><![CDATA[Ever since the advent of the internet, Java has been the target for many developers. Many C++ developers migrated to Java within a short period of time. Many high quality multithreaded animations, games, distributed applications are being developed and implemented successfully. Moreover the java language is completely platform independent. You can go through the java [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript">
<!-- 
lqm_channel=1;
lqm_publisher=175;
lqm_zone=1;
lqm_format=7;
//-->
</script>
<script type="text/javascript" src="http://a.lakequincy.com/s.js"></script></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.learnxpress.com%2Fa-comparison-between-java-and-c.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.learnxpress.com%2Fa-comparison-between-java-and-c.html&amp;style=normal" height="61" width="50" title="A comparison between Java and C#" alt="A comparison between Java and C#" /><br />
			</a>
		</div>
<p>Ever since the advent of the internet, Java has been the target for many developers. Many C++ developers migrated to Java within a short period of time. Many high quality multithreaded animations, games, distributed applications are being developed and implemented successfully. </p>
<p> <span id="more-162"></span>
<p>Moreover the java language is completely platform independent. You can go through the java tutorial topics on this web site if you are having any doubt. </p>
<p>Java programs called Applets are verified for security in user&#8217;s machine before downloading, thus ruling out the possibility for any viruses creeping into the user&#8217;s machine. Many new advancements like swing package, Java2D API, Networking packages (java. net) have been built into the language after the initial release of Java Development Kit. Since Java is from Sun Microsystems many of its rival companies have started creating an alternative to this hot programming language, some two years back.    </p>
<p>Now a company which needs no further introduction, Microsoft have come up with a technology called Microsoft. NET. One of the prime languages in the .NET family is C# or C-Sharp. This language was derived from Java/C++. Technically from my experience with C# for over 6 months, I am of the opinion that C# is more or less similar to Java. But many of the features of C++ like operator overloading (which was removed from Java) are there in C#.</p>
<p>Java programs will run on any platform having Java Virtual Machine or JVM installed on it. But .NET programs targets Platforms having Common Language Runtime or CLR. This is the runtime which is being used by all the .NET Languages for the execution. Thus one .NET language can call the modules and functions written on another .NET Language. With .NET you can perform server side Programming via ASP. NET, like Servlets in Java. </p>
<h1>Java Applets Vs .NET</h1>
<p>In the last Session, we have dealt with Java Applets. Now you may be having questions like, is the alternative for Applets in .NET in the mind. My answer is yes, there is an alternative to Applets in .NET. It is called WinForms Applications. With WinForms you can design and develop windows based applications. This can be achieved through Code with C# or by using Development Environment tools like Visual C#. </p>
<p>WinForms is almost similar to win32 applications which we develop using Visual C++. It is possible to develop these applications using C++. But VC++ simplifies our development effort by providing us with Wizards. Now Visual C# is also doing the same work. So if you are already a VC++ developer, it will be better for you to try out VC#. </p>
<p><b>HelloWorld Java Program</b></p>
<pre>class Hello {public static void main(String args[]) {System.out.println(&quot;HelloWorld&quot;);
}
}</pre>
<p><b>HelloWorld C# Program</b></p>
<pre>class Hello {public static void Main() {Console.WriteLine(&quot;Hello world&quot;);
}
}</pre>
<pre>&#160;</pre>
<h1>Other Notable Differences</h1>
<p>
  <br /><b>Main Method</b></p>
<p>Java: It is possible to compile a Java program without a main method, provided that class is used as a super class. However the program will execute only when there is a valid main method in the class. </p>
<p>C#: It is not possible to compile a C# source file without a valid main method. If it is absent, then the compiler will show an error message like program &#8216;filename.exe&#8217; does not have an entry point defined.</p>
<p><b>Inheritance</b></p>
<p>Both Java and C# doesn&#8217;t supports multiple inheritance and provides interfaces as an alternative to it. However C# covers much more advanced issues in interfaces. Please check out the topic titled New Additions given at the end of this article. </p>
<p><b>Operators and control flow statements</b></p>
<p>All operators like Arithmetic, logical, increment and decrement etc available in Java are supported by C#. Moreover control flow statements like if, else, if-else, for, do-while, while etc included with Java are also available in C#. However C# reintroduces the popular GoTo statement found in C++. </p>
<p><b>Exception Handling</b></p>
<p>You can handle runtime errors also called as Exceptions in C# by making use of try, catch, finally, throws clauses. Exception handling in C# is almost same as in Java except some minor differences. System.Exception namespace is the base class of all the exception classes in C#. </p>
<p><b>Multithreading</b></p>
<p>The application of Multithreading in C# is much more simplified, than in Java. We can synchronize threads by making use of the Monitor and Mutex classes. </p>
<p><strong>New Additions</strong></p>
<p>The concept of Indexers, Attributes and Delegates are new to C#. Indexers are almost similar to Vectors in Java. A complete discussion related to these new concepts are beyond the scope of our discussion. However, I will try to explain these at an another occasion through this site. C# introduces the concept of operator overloading, which was not present in Java. However both Java and C# supports Method overloading and Method overriding.</p>
<p>Coming back to interfaces, we can verify whether the methods included within an interface are implemented by using is and as operators. There are ways to avoid name ambiguity while implementing the interface methods. You can even combine two interfaces into one and implement that combined interface in a class like the following piece of code: </p>
<pre>using System;public interface First {void A();void B();
}public interface Second {void C();
}public interface Combined: First, Second { }
class Combineimple: Combined {// statements goes here// main method goes here}
}			</pre>
<p>Further, C# compiler shows the compile time error messages along with their error numbers. You can search the online documentation that comes with the SDK for the error number to study the cause of the error in detail.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.learnxpress.com/a-comparison-between-java-and-c.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Understanding Multithreading in Java</title>
		<link>http://www.learnxpress.com/understanding-multithreading.html</link>
		<comments>http://www.learnxpress.com/understanding-multithreading.html#comments</comments>
		<pubDate>Fri, 16 Jan 2009 06:23:36 +0000</pubDate>
		<dc:creator>Anand Narayanaswamy</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://www.learnxpress.com/en/2009/01/16/understanding-multithreading/</guid>
		<description><![CDATA[Java provides built in support for multithreaded programming. A Multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a Thread. Each thread defines a separate path of execution. Multithreading is a specialized form of Multitasking. Multitasking is divided into two types. They are (1) Process [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.learnxpress.com%2Funderstanding-multithreading.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.learnxpress.com%2Funderstanding-multithreading.html&amp;style=normal" height="61" width="50" title="Understanding Multithreading in Java" alt="Understanding Multithreading in Java" /><br />
			</a>
		</div>
<p>Java provides built in support for multithreaded programming. A Multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a Thread. Each thread defines a separate path of execution. Multithreading is a specialized form of Multitasking.</p>
<p><span id="more-52"></span></p>
<p>Multitasking is divided into two types. They are</p>
<p>(1) Process based: Here two or more programs runs concurrently. You can run Windows calculator and a Text editor (Notepad) at the same time.</p>
<p>(2) Thread based: A single program can perform two or more tasks simultaneously. For example, text editor can print while formatting is being done.</p>
<p>Multithreading enables you to write very efficient programs that make maximum use of CPU, because idle time can be kept to minimum. This is especially important for the interactive networked application because idle time is common. In a traditional single threaded environment, your program has to wait for each of the tasks to finish before it can proceed to the next one. This will result in idle time. Multithreading lets you gain access to this idle time and put it to good use.</p>
<h1>Java&#8217;s Model of Thread</h1>
<p>One thread can pause without stopping other parts of your Program. Multithreading allows animation loops to sleep for a second between each frame without causing the whole system to pause. When a thread blocks in a java program, only the single thread that is blocked pauses. All other threads continue to run.</p>
<p>Also note the following points regarding threads.</p>
<p>(1) A thread can be running. It can be ready to run as soon as it begins execution<br />
(2) A running thread can be suspended which temporarily suspends its activity<br />
(3) A suspended thread can be resumed<br />
(4) A thread can be blocked when waiting for a resource. (sleeps for a while)</p>
<p>At any time a thread can be terminated, which means the thread stops. Once stopped it cannot be resumed.</p>
<h1>Thread priorities</h1>
<p>Thread priorities are integers that specify the relative priority of one thread to another. Higher priority thread doesn&#8217;t run any faster than a lower priority thread. Instead a thread’s priority is used to decide when to switch from one running thread to the next This is called as context switch. A thread can have a maximum priority of 10 and a minimum of 1. Normal Priority is 5.</p>
<h1>Thread class Methods</h1>
<p>start() –&gt; Starts execution of the thread.<br />
stop() –&gt; Terminates the current thread.<br />
suspend() –&gt; Suspends the thread.<br />
resume() –&gt; Restarts the suspended thread.<br />
sleep() –&gt; This method suspends execution of the executing thread for the specified number of milliseconds. It can throw an interrupted Exception.</p>
<p>getName() –&gt; Obtains a thread name.<br />
getPriority() –&gt; Obtain a thread’s priority.<br />
Isalive() –&gt; Determine if a thread is still running.<br />
wait() –&gt; Waits for a thread to terminate.<br />
run() –&gt; Entry point for the Thread.</p>
<p>When a java program starts up, one thread begins running immediately. This is usually called the main thread of your program, because it is the one that is executed when your program begins. Main thread will be the last thread to finish execution. When the main thread stops<br />
your program terminates.</p>
<h1>Creation of a thread</h1>
<p>You can create a thread in one of the following ways</p>
<p>(1) You can implement the Runnable Interface and apply its run() method.</p>
<p>(2) You can extend the Thread class itself.</p>
<p>(1) Implementing Runnable Interface: The easiest way to create a thread is to create a class that implements the Runnable interface. To implement Runnable, a class need only implement a single method called run(). The Format of that function is public void run().</p>
<p>2. Extending Thread: The second way to create a thread is to create a new class that extends the Thread class and then to create an instance of this class. This class must override the run() method which is the entry point for the new thread.</p>
<h1>Synchronization in Java</h1>
<p>1. Two or more threads accessing the same data simultaneously may lead to loss of data integrity. In order to avoid this java uses the concept of monitor. A monitor is an object used as a mutually exclusive lock.</p>
<p>2. At a time only one thread can access the Monitor. A second thread cannot enter the monitor until the first comes out. Till such time the other thread is said to be waiting.</p>
<p>3. The keyword Synchronized is use in the code to enable synchronization and it can be used along with a method.</p>
<h1>Inter Thread Communication</h1>
<p>There may be cases where one of the created threads require data from another thread. Java achieves this through the usage of wait(), notify(), notifyAll() methods of the object class.</p>
<p>wait() –&gt; This method waits indefinitely until it receives a notification<br />
notify() –&gt; This wakes up a single thread waiting on the objects monitor.<br />
notifyAll() –&gt; This wakes up all the threads waiting on the objects monitor.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.learnxpress.com/understanding-multithreading.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
