We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

Assignment No. 04 Semester: Spring 2015 Visual Programming-CS411 Total Marks: 20 Due Date: 10/Aug/2015

Assignment No. 04
Semester: Spring 2015
Visual Programming-CS411

 

Total Marks: 20

 

Due Date: 10/Aug/2015

Instructions:                          

Please read the following instructions carefully before submitting assignment:

  • You will submit your assignment before or on due date on VU-LMS.
  • Assignment should be completed by your own efforts it should not be copied from internet, handouts or books.
  • You should submit your .doc File via assignment interface at VU-LMS.
  • Assignment sent via Email will not be replied and accepted in any case.
  • If the submitted assignment does not open or file is corrupt, it will not be marked.
  • You will submit solution only in document (.doc or .docx) File.

Objectives:

To build the programming practices and understandability of concurrency controls in C#.

For any query about the assignment, contact at cs411@vu.edu.pk

Assignment Questions

 

Question:                                                                                                                               Marks 20     

 

Write a program in C# to demonstrate that, as a high-priority thread executes, it will delay the execution of all lower-priority threads.

 

Bonus Marks:

Those students who thinks that they are good programmer or they have good commands on Multithreading. They can win bonus marks to improve their CGP. The selected students will also be declared as shining stars on course website.

 

To participate in this competition, send your request to cs411@vu.edu.pk before August 7, 2015, 12:00 PM. I will choose up to five students by giving them a small programming tasks in a live session. Procedure and schedule will be replied to selected emails only.

 

BEST OF LUCK

 


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)


Views: 2115

Attachments:

Replies to This Discussion

Dear Fellows come here and share your ideas....

Idea for this Assignment:

public static void main( String args[] )
{
HighPriorityThread highThread = new HighPriorityThread();
LowPriorityThread lowThread = new LowPriorityThread();

lowThread.start();
highThread.start();
}
}


public class HighPriorityThread extends Thread {

public HighPriorityThread()
{
super( "High Priority Thread" );

setPriority( 10 );
}

public void run()
{
System.err.println( getName() + " has started running" );

try {
Thread.sleep( 2000 );

System.err.println( getName() + " is still running after 2 seconds" );

for ( int i = 0; i < 5; i++ ) {
Thread.sleep( 2000 );
System.err.println( getName() + " is still running after "
+ ( i * 2 + 4 ) + " seconds" );
}

System.err.println( getName() + " has now terminated" );
}

catch ( InterruptedException e ) {
System.err.println( e.toString() );
}
}
}


public class LowPriorityThread extends Thread {

public LowPriorityThread()
{
super( "Low Priority Thread" );

setPriority( 5 );
}

public void run()
{
System.err.println( getName() + " has started running" );

try {
Thread.sleep( 2000 );

System.err.println( getName() + " is still running after 2 seconds" );

for ( int i = 0; i < 5; i++ ) {
Thread.sleep( 2000 );
System.err.println( getName() + " is still running after "
+ ( i * 2 + 4 ) + " seconds" );
}
}

catch ( InterruptedException e ) {
System.err.println( e.toString() );
}

System.err.println( getName() + " has now terminated" );
}
}

Thanks zain bhai is this complete solution

ya complete codde hy kia 

Please Discuss here about this assignment.Thanks
Our main purpose here discussion not just Solution
We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

zain bhai is coding ko run kr k us ka screen shot upload kein ta k hmain b pta chly is ki output kya ai hy ,,,,I mean hmari wali output sy match hoti ya nai.....
kya ye complete coding hy ?

koi discus to kro plz

Multitreading program output

Attachments:
Multithreading
 Multithreading is used to perform multiple tasks at the same time. Tasks with the potential of holding up other tasks can execute on separate threads, a process known as multithreading. Or, it's basically trying to do more than one thing at a time within a process.

CS411 Complete Solution by Zain

“Write a program to demonstrate that, as a high-priority thread executes, it will delay the execution of all lower-priority threads.”

public class ThreadCounter
{
public ThreadCounter( )
{
_continue = true;
}

public Boolean Continue
{
set { _continue = value; }
}

public void Count( )
{
Int32 i__ = 0;

while ( _continue )
{
i__++;
}
Console.WriteLine( "{0} has a count = {1}", Thread.CurrentThread.Name, i__ );
}

private bool _continue;
}

internal class Program
{
private static void Main( )
{
const Int32 TimeoutMilliSeconds = 5000;
ThreadCounter priorityTest = new ThreadCounter( );
ThreadStart startDelegate = new ThreadStart( priorityTest.Count );

Thread threadOne = new Thread( startDelegate );
threadOne.Name = "Highest Priority Thread";
Thread threadTwo = new Thread( startDelegate );
threadTwo.Name = "Lowest Priority Thread";

threadOne.Priority = System.Threading.ThreadPriority.Highest;
threadTwo.Priority = System.Threading.ThreadPriority.Lowest;
threadOne.Start( );
threadTwo.Start( );

Console.WriteLine( "Putting thread to sleep for 5 seconds... Please wait!" );
Thread.Sleep( TimeoutMilliSeconds );
priorityTest.Continue = false;
Console.ReadLine( );
}
}

The results look something like this… the counts will be different based on the speed of you CPU, whether you have a single core, duo core or hyper threading!

 

Spring 2015_CS411- Assignmnt # 4 Solution BY Zain

Attachments:

RSS

Looking For Something? Search Here

HELP SUPPORT

This is a member-supported website. Your contribution is greatly appreciated!

© 2020   Created by +M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.