Friday, March 13, 2020
Threading Introduction in Visual Basic
Threading Introduction in Visual Basic To understand threading in VB.NET, it helps to understand some of the foundation concepts. First up is that threading is something that happens because the operating system supports it. Microsoft Windows is a pre-emptive multitasking operating system. A part of Windows called the task scheduler parcels out processor time to all the running programs. These small chunks of processor time are called time slices. Programs arent in charge of how much processor time they get, the task scheduler is. Because these time slices are so small, you get the illusion that the computer is doing several things at once. Definition of Thread A thread is a single sequential flow of control. Some qualifiers: A thread is a path of execution through that body of code.Threads share memory so they have to cooperate to produce the correct result.A thread has thread-specific data such as registers, a stack pointer, and a program counter.A process is a single body of code that can have many threads, but it has at least one and it has a single context (address space). This is assembly level stuff, but thats what you get into when you start thinking about threads. Multithreading vs. Multiprocessing Multithreading is not the same as multicore parallel processing, but multithreading and multiprocessing do work together. Most PCs today have processors that have at least two cores, and ordinary home machines sometimes have up to eight cores. Each core is a separate processor, capable of running programs by itself. You get a performance boost when the OS assigns a different process to different cores. Using multiple threads and multiple processors for even greater performance is called thread-level parallelism. A lot of what can be done depends on what the operating system and the processor hardware can do, not always what you can do in your program, and you shouldnt expect to be able to use multiple threads on everything. In fact, you might not find many problems that benefit from multiple threads. So, dont implement multithreading just because its there. You can easily reduce your programs performance if its not a good candidate for multithreading. Just as examples, video codecs may be the worst programs to multithread because the data is inherently serial. Server programs that handle web pages might be among the best because the different clients are inherently independent. Practicing Thread Safety Multithreaded code often requires complex coordination of threads. Subtle and difficult-to-find bugs are common because different threads often have to share the same data so data can be changed by one thread when another isnt expecting it. The general term for this problem is race condition. In other words, the two threads can get into a race to update the same data and the result can be different depending on which thread wins. As a trivial example, suppose youre coding a loop: For I 1 To 10 DoSomethingWithI()Next If the loop counter I unexpectedly misses the number 7 and goes from 6 to 8- but only some of the time- it would have disastrous effects on whatever the loop is doing. Preventing problems like this is called thread safety. If the program needs the result of one operation in a later operation, then it can be impossible to code parallel processes or threads to do it.Ã Basic Multithreading Operations Its time to push this precautionary talk to the background and write some multithreading code. This article uses a Console Application for simplicity right now. If you want to follow along, start Visual Studio with a new Console Application project. The primary namespace used by multithreading is the System.Threading namespace and the Thread class will create, start, and stop new threads. In the example below, notice that TestMultiThreading is a delegate. That is, you have to use the name of a method that the Thread method can call. Imports System.ThreadingModule Module1 Sub Main() Dim theThread _ As New Threading.Thread( AddressOf TestMultiThreading) theThread.Start(5) End Sub Public Sub TestMultiThreading(ByVal X As Long) For loopCounter As Integer 1 To 10 X X * 5 2 Console.WriteLine(X) Next Console.ReadLine() End SubEnd Module In this app, we could have executed the second Sub by simply calling it: TestMultiThreading(5) This would have executed the entire application in serial fashion. The first code example above, however, kicks off the TestMultiThreading subroutine and then continues. A Recursive Algorithm Example Heres a multithreaded application involving calculating permutations of an array using a recursive algorithm. Not all of the code is shown here. The array of characters being permuted is simply 1, 2, 3, 4, and 5. Heres the pertinent part of the code. Sub Main() Dim theThread _ As New Threading.Thread( AddressOf Permute) theThread.Start(5) Permute(5) Console.WriteLine(Finished Main) Console.ReadLine()End SubSub Permute(ByVal K As Long) ... Permutate(K, 1) ...End SubPrivate Sub Permutate( ... ... Console.WriteLine( pno pString) ...End Sub Notice that there are two ways to call the Permute sub (both commented out in the code above). One kicks off a thread and the other calls it directly. If you call it directly, you get: 1 123452 12354... etc119 54312120 54321Finished Main However, if you kick off a thread and Start the Permute sub instead, you get: 1 12345Finished Main2 12354... etc119 54312120 54321 This clearly shows that at least one permutation is generated, then the Main sub moves ahead and finishes, displaying Finished Main, while the rest of the permutations are being generated. Since the display comes from a second sub called by the Permute sub, you know that is part of the new thread as well. This illustrates the concept that a thread is a path of execution as mentioned earlier. Race Condition Example The first part of this article mentioned a race condition. Heres an example that shows it directly: Module Module1 Dim I As Integer 0 Public Sub Main() Dim theFirstThread _ As New Threading.Thread( AddressOf firstNewThread) theFirstThread.Start() Dim theSecondThread _ As New Threading.Thread( AddressOf secondNewThread) theSecondThread.Start() Dim theLoopingThread _ As New Threading.Thread( AddressOf LoopingThread) theLoopingThread.Start() End Sub Sub firstNewThread() Debug.Print( firstNewThread just started!) I I 2 End Sub Sub secondNewThread() Debug.Print( secondNewThread just started!) I I 3 End Sub Sub LoopingThread() Debug.Print( LoopingThread started!) For I 1 To 10 Debug.Print( Current Value of I: I.ToString) Next End SubEnd Module The Immediate window showed this result in one trial. Other trials were different. Thats the essence of a race condition. LoopingThread started!Current Value of I: 1secondNewThread just started!Current Value of I: 2firstNewThread just started!Current Value of I: 6Current Value of I: 9Current Value of I: 10
Wednesday, February 26, 2020
Employment Law - Employment Discrimination Research Paper
Employment Law - Employment Discrimination - Research Paper Example This research will begin with the statement that employment discrimination is defined as the adoption of lesser ways of dealing with other employees or potential employees based on their demographic characteristics. In such instances, employees are treated based on their gender, race, age and even religion, thus affecting the chances of certain individuals from acquiring employment. Discrimination, though common in different parts of the world, is disastrous to the economy as potential employees with the ability to deliver are excluded from the market. In Saudi Arabia, gender employment discrimination is common and this has been attributed to the conservative religious culture in the country. The Islamic law and the social norms and traditions in the country have retracted economic progress in the country, a factor that is attributed to the disparity. According to a report released by the human rights watch, the level of gender discrimination at the workplace has significantly increa sed in Saudi Arabia. This, the report attributes to the various employment requirements that have been put in place in the country based on the sharia laws. The belief expressed by this report that gender discrimination has increased in Saudi Arabia does not put into account the traditional need to protect women in society, especially those in the workplace. As a result, for a woman to enter into an organization, she is placed under the supervision and leadership of a male supervisor.
Sunday, February 9, 2020
M3 Mortality Data Paper Essay Example | Topics and Well Written Essays - 500 words
M3 Mortality Data Paper - Essay Example It helps to determine the competence of health facilities, the efficiency of drugs used by specific patients and the effects of lifestyle habits on health (Shi, 2008).à à Mortality data is limited because it cannot accurately determine future death trends. Socio-economic factors, socio-political factors, lifestyle habits, natural calamities, and migration influence the value of the data since these factors are significant especially when authorities manipulate them. Therefore, mortality data is limited in the mode of collection and interpretation. Most deaths go unreported, especially those that do not occur in health institutions. Consequently, deaths that do not occur in hospitals are rarely investigated.à This may result in wrong recording and interpretation of recorded data (McKenzie et al., 2012). Additionally, recording of death in the health departments may lead to multiple records, thus distorting the figures. Descriptive research attempts to explore the health problem extensively through the analysis of mortality data. à In understanding the problem, descriptive research engages the three elements of time, place and person in integrative ways and relates findings with emerging phenomena. It appraises the regularity and pattern of the three elements as they influence public health (McKenzie et al., 2012). It also evaluates the circumstances defining a person by assessing the social patterns causing ill health and mortality. Place implies the geographic locality and its features that are likely to influence health. By studying a place, epidemiologists assess the incidences of diseases and the causation factors in the environment (Shi, 2008). Place may imply the environmental surroundings such as school, workplace, and the population density of an area. In evaluation of ââ¬Å"person,â⬠factors of social status, age, education levels, gender and access to health services are assessed .à The research also evaluates personal habits
Thursday, January 30, 2020
Boston Beer Company Essay Example for Free
Boston Beer Company Essay 1.Evaluate the attractiveness of the craft beer segment relative to the market space occupied by the traditional Big Three. (tip: use the Five Forces framework). a.High Threat of new competition: over 600 of specialty beer companies were founded over the past five years, approximately 40% growth each years. In addition, the existence of contract brewing companies lead to low entry cost. b.High substitution: The attractiveness of craft brewing industry are majorly based on unique styles and flavors of beer. there are many different brands and styles of beer so the actual threat of substitutes is high. c.The intensity of competitive rivalry is also high: while there is a major growth of new entry, the market size shows little growth. This creates tremendous competitive pressures among the industry. d.Bargaining power of buyers: Switching cost for buyers are low, as there are many different substitution and options. companies has to consistently maintain high quality in order to retain customers. e.Bargaining power of suppliers: switching cost for suppliers are high for the traditional Big Three, as their supplies are tied to their own brewies. Craft brewing companies has the option of switch breweries in a relatively low cost, as the suppliers know they have options to supply other breweries. This allows them to charge higher prices than the big three. 2.Evaluate Boston Beers business model relative to Redhook and Petes, comparing their business models with respect to specific activities such as procurement, brewing, distribution, and marketing. BBCââ¬â¢s strategy of producing the highest quality of products, the company pursued four initiatives: high quality standards, contract brewing, intensive sales and marketing, and product line innovations. Unlike BBC and Peteââ¬â¢s, redhook relies on its own breweries. Redhook also established a strategic alliance with Anheuser-Busch whereby Redhook products were sold through the nation-wide network of 700 distributorships in exchange for a 25% equity stake in the company. \Similar to BBC, Peteââ¬â¢s operates on a contract brewing basis and stress heavily on marketing. In retrospect, BBC intended to remain a contract brewer exclusively, capitalizing on lower overhead and transportation costs while continuing to invest heavily in its branded products. Redhook believed that its long-term growth and profitability were best served by assembling the largest company-owned production capacity of any domestic craft brewer, guaranteeing production capacity in more than one geographic region of the United States. Redhook also made a substantial investment in distribution, gaining access to Anheuser Buschââ¬â¢s nation-wide network of resellers. Peteââ¬â¢s, on the other hand, appeared to be following a combination of these two strategies by producing its products at both company-owned and third-party breweries. 3.How realistic analysts long-term growth forecasts (25% to 40% for the craft-brewing segment)? Based on the porter five forces analysis, the craft brewing segment has many advantages over the traditional big three, which explains the 40% growth rate. However the large number of new entries companies has already created a tremendous amount of competitions among its own, which retard the long term growth in my opinion and makes the forecasts of 25% to 40% seem unrealistic. 4.What do you recommend to Boston Beer? a.While the US market size remains somewhat stable. By exporting globally, will introduce BBC to new markets and additional sales b.Forming strategic alliance will help combat the increasing competition among industries.
Wednesday, January 22, 2020
Argument in Favor of Gun Control Essay -- Argumentative Persuasive Exa
ââ¬Å"Almost twelve kids lose their lives every single day because of gunsâ⬠(Capps). Most recently, two young boys were shot as they were leaving a high school football game. Soon, another year anniversary of the Columbine High School shooting will arrive. In this incident, two students opened fire on their classmates in Columbine. I cannot imagine the horrors of my fellow students being killed by guns! Many other related acts of gun violence have brought up issues on gun control. Debates have risen between citizens on how the government should establish stronger gun control laws. Despite the National Rifle Association strong objections against these issues, gun control laws must be increased. Many citizens agree that gun control laws must be established, because of the recent acts of violence committed with guns. The gun control issues take a heated debate, because now kids are targets of gun violence. In the Columbine shooting, both students purchased their weapons at a gun show with the help of an eighteen-year-old friend (Sanko). If the gun show provider was forced by law to do a background check the two students wouldnââ¬â¢t have received the guns. As of right now background checks are only done on weapons that are purchased from federally licensed dealers. This is one reason for new gun control laws. The death of Kayla Rolland, on February 20, 2012, is a another reason for new gun control laws. Kayla was gunned down in her elementary school by a six year old classmate (Smolowe). The child obtained the gun with the help of his father. His father had left the gun on the living room table. As of right now guns are not required to have child safety locks. Moreover, kids can get guns without the help of a friend o... ...their own classmates. Lastly, the control of gun manufacturing will decrease the availability of guns on the streets New gun control laws are important to the children of today and tomorrow. The power lies behind the government and unfortunately the National Rifle Association. Works Cited Capps, Louis. ââ¬Å"Capps Continues Fight for Common Sense Gun Control.â⬠FDCH Press Releases. 3 Mar. 2014. Harrington-Lueker, Donna. ââ¬Å"Blown Away by School Violence.â⬠Education Digest. 58.3 (2013): 50, 4. Lazar, Daniel. ââ¬Å"Your Constitution is Killing You.â⬠Harperââ¬â¢s Magazine. 299.1793 (2011): 57,9. Reynolds, Rhonda. ââ¬Å"Kids Who Kill.â⬠Black Enterprise. (2013): 47,1. Sanko, John. ââ¬Å"Gun-control Measureââ¬â¢s Wording for Vote Framed.â⬠Denver Rocky Mountains News Capital Bureau. 4 April. 2012. Smolowe, Jill., et al. ââ¬Å"Fallen Angel.â⬠People. (2014): 66,2.
Tuesday, January 14, 2020
Good vs Evil in King Lear Essay
Life will always bestow us with choices which we must wisely choose either a moral or immoral response to. Shakespeare exemplifies goodness and wickedness in King Lear. The play presents a powerful manifestation of loyalty, specifically through the characters Kent, Edgar, and Cordelia. Kentââ¬â¢s unrestricted loyalty to Lear remains stable throughout the play. He recognizes Learââ¬â¢s tragic flaw and remains faithful, even after being banished. His reliability is further divulged when he attacks Oswald, Gonerilââ¬â¢s loyal servant. Kentââ¬â¢s defensive actions result in him being placed in the stocks. This sacrifice adds to his loyal attitude of pursuing the Kingââ¬â¢s well-being and safety. Oswald is loyal to Goneril, and acts well as a contrasting character to Kent. They both share the attribute of loyalty; however Oswaldââ¬â¢s loyalty is based on immoral decisions, while Kentââ¬â¢s is not. Following Learââ¬â¢s death, Kent foreshadows that he too will pass on, reuniting himself with Lear. Furthermore, Edgar is betrayed by his evil, manipulative brother, and he is forced to disappear. Edgarââ¬â¢s goodness is displayed when he treats Gluocester with kindness, regardless of his fatherââ¬â¢s misjudgment. In addition, Edgar gives his father strength by saving his life making him believe a deity has saved him from jumping off a cliff. This renaissance causes Gluocester to think and act more wisely in future endeavors. Edgar and Kentââ¬â¢s morality and loyalty are not affected by their mistreatment provided by their superiors, which ultimately verifies them as accurate symbols of good. Cordelia is an exemplar for true virtue in her acts of forgiveness and loyalty towards her father. Lear, distressed by his beloved daughterââ¬â¢s response of ââ¬Å"nothingâ⬠to his love test, banishes Cordelia and denies her any land and power. Lear turning his back on Cordelia foretells destruction, since she is one of the only people in Learââ¬â¢s life that is loyal and expressââ¬â¢s genuine feelings towards him. Furthermore, she foreshadows her death by returning to the kingdom to the aid of her father. She understands the dangers of returning, but despite these dangers she continues to emanate loyalty. Shakespeare delivers the existence of suffering through the presence of good and evil. Through Kent, Edgar, and Cordelia, Shakespeare has made it apparent that evil is unavoidable, yet virtue, loyalty, and forgiveness is rooted to everyone. It takes certain individuals to have the courage and power to be able to express these moral characteristics.
Monday, January 6, 2020
An Everlasting Relationship in Elie Wieselôs Night
Miller Park would need to be filled to capacity 262 times to equal the eleven million total people that died during the Holocaust. Jews, gypsies, homosexuals, and many others were killed for no other reason than being hated by the Nazis for who they are. In Elie Wieselââ¬â¢s memoir Night, he tells the petrifying experiences he suffered through that scarred him forever. Some things can never be unseen, and this was the case for Wiesel. If it were not for his father, his last bit of hope for life would have been shattered, and he would not have survived. As each horrifying event unfolds at the concentration camps, the true strength of the relationship between Elie Wiesel and his father shows and progressively gets stronger throughout their timeâ⬠¦show more contentâ⬠¦Being able to share this key belief with his father allows their relationship to continue to grow stronger. As their time in the concentration camp continues, the conditions there worsen. The prisoners are soon f orced into a treacherous forty-two mile run in the icy cold, which makes them struggle between life the death. During this march, one thing keeps Wieselââ¬â¢s will to live alive and that is his father. This shows one of Wieselââ¬â¢s weakest moments, where he contemplates giving up numerous times. Exhaustion takes over his body, and the only thing he can think about is the pleasures that death would bring him. Wieselââ¬â¢s mind overpowers him and he reflects, ââ¬Å"Death wrapped itself around me till I was stifled. It stuck to me. I felt that I could touch it. The idea of dying, of no longer being, began to fascinate meâ⬠(82). However, his father needs him, and that is truly what drives him to keep pushing until the end. They stay alive for each other, which shows how much they really care about the other. While Wiesel rests in the shed after the run, Rabbi Eliahou, a very well-liked man, comes in looking for his son. He and his son have been sticking together for thr ee years. Wiesel expresses that he has not seen him, without realizing that this is false. The Rabbiââ¬â¢s son purposely left him, to strengthen his own chances of survival. Wiesel is taken aback by this, and astonishingly begins to pray. He thinks, ââ¬Å"My God,Show MoreRelatedNight, By Elie Wiesel1362 Words à |à 6 Pagesthe right questions.â⬠(5) In Elie Wiesel s novel ââ¬Å"Night,â⬠we find the horrific life story of a father and son during the period of the devastating Holocaust. Elie and his father need to unite in order to survive through the excruciation. We find a transition of indifference by Elie during his Nobel Peace Prize. From his love for life to not caring about anything, Elie matures as the book progresses. He learns to value his father and stick together. In ââ¬Å"Night,â⬠Elie Weisel utilizes the fear of survivingRead MoreAnalysis Of The Night By Elie Wiesel1385 Words à |à 6 PagesIn the Night, author Elie Wiesel provide the readers with an insight of how determination became the guidance for the Jewish people who suffered dreadful torture and endured a horrid lifestyle under the Naziââ¬â¢s fascist and anti-semitic regime. Furthermore, due to continuous bombardment from the Germanââ¬â¢s; Eliezer, Chlomo, and the rest of the Jewish population found themselves indecisive of their faith u pon their God, the legitimacy of a just society and the permanence of a familyââ¬â¢s relationship. TheRead MoreElie Wiesel : The Survivor Of The Holocaust2445 Words à |à 10 Pagesillness, an abusive relationship, a violent incident, or the loss of a loved one. However, some experiences are more devastating than others. Each survivor has his/her way of coping with the trauma and maintaining sanity. Elie Wiesel, one the survivors of the Holocaust, gives us some insight into dealing with extremely difficult experiences. He spent a year imprisoned in the Auschwitz and Buchenwald concentration camps, the same camps where he lost all his family members (Wiesel 15). After his liberation
Subscribe to:
Posts (Atom)