Disposing of Threads & Resource Properly (after finished task)


So I have been working on a program lately, or actually was working on it and came back to check on it. The program is being developed for someone else, who unfortunately has not been cooperative in giving me the stuff I need to test it. The program is used to read in a webpage, parse its data, and then notify if changes have occurred.


Now this program involves using Threads, something that while I understand the concept of, and have gone over, I have never really implemented into a program like this (I have used BackgroundWorkers before but this is not the same).


Well from what I can tell the program actually works as intended. While I am unable to get the site needed to test it, I have been giving it other sites to give me general results. The program I know reads in results and does indeed try to update the form (it yelled at me saying it couldn't add rows until it had columns ... hazaa I got this far).


I decided to test the code today, as I mentioned before I hadn't worked on it in awhile, and everything seems fine (again like I said before). I also ran task manager and monitored the resources of the program, and here lies the problem ... I think I have a memory leak. Let me show you the code and I'll explain more after that.



```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace ScoreTableDetector2_1v1
{
    public delegate void Return_CallBack(string downloadedData);
    public delegate void Return_FormData(List<teamDataItem> tempData, string rtbData);
    public delegate void SetRTBCallback(string text);
    public delegate void SetDGV_New_Callback(teamDataItem tempEntry);
    public delegate void SetDGV_Edit_Callback(teamDataItem tempEntry);
//
    public partial class Form1 : Form
    {
        //!!!! - NEED to dispose of the thread and its resources when it's finished, primarily speaking of the delegate called threads for the form and parsing data.

        private Object thisLock = new Object();
        private Object lockFormUpdate = new Object();

        private Thread updateForm_Thread = null;
        private Thread updateForm_Thread_num2 = null;

        List<teamDataItem> teamData;

        List<string> pointFields;
        List<string> flagNames;

        Thread readInThread = null;
        string url;
        int elapsedTime;

        readInWebpage readIn;
//
        public Form1 ()
        {
            InitializeComponent();

            teamData = new List<teamDataItem>();

            pointFields = new List<string>() { };
            flagNames = new List<string>() { };

            url = "<http://www.reddit.com/new/>";
            elapsedTime = 15;

            readIn = new readInWebpage(url, "", elapsedTime, new Return_CallBack(updateForm));

            button2.Enabled = false;

            setupDataGridView.setup(ref pointFields, ref flagNames, ref dataGridView1); //used to set up the columns
        }
//
        private void button1_Click (object sender, EventArgs e) //start
        {
            checkWebsite();
        }
//
        private void button2_Click (object sender, EventArgs e) //stop
        {
            readInThread.Abort();

            button2.Enabled = false; //change over the state of the buttons to prevent double click issues
            button1.Enabled = true;
        }
//
        private void checkWebsite () //used to start the thread
        {
            this.readInThread = new Thread(readIn.runScan);
            readInThread.Start();

            button2.Enabled = true; //change over the state of the buttons to prevent double click issues
            button1.Enabled = false;
        }
//
        private void updateForm (string downloadedData) //the delegate class to call back to 
        {
            lock (thisLock) //lock (mutex style)
            {
                this.updateForm_Thread = new Thread(() => parseData.strip(teamData, downloadedData, pointFields, flagNames, new Return_FormData(updateForm_Data))); //parse the data
                this.updateForm_Thread.Start();

                //!!! when the updateForm_Data() function is called, this needs to be disposed of
            }
        }
//
        private void updateForm_Data (List<teamDataItem> tempData, string rtbData) //call back by the parseData
        {
            lock (lockFormUpdate) //lock off the form update to one class
            {
                this.updateForm_Thread_num2 = new Thread(() => thread_UpdateFormSafe(tempData, rtbData)); //used to actually apply the updated data to the form
                this.updateForm_Thread_num2.Start();

                //!!! once the form has been updated this needs to be disposed of
            }
        }
//
        private void thread_UpdateFormSafe (List<teamDataItem> tempData, string rtbData) //used to update the form data
        {
            //!!!!! I NEVER UPDATE THE COMBOBOX (needs to be done through new entry only)

            //if index == -1, and newEntry == true, then it's a new entry
            //if index != -1, and newEntry == false, then it's an old entry who's value changed
            //if index == -1, and newEntry == false, then it's an old entry that was unchanged


            for (int i = 0; i < tempData.Count; i++) //go through the list 
            {
                if (tempData [i].newEntry == true) //if a new entry was added
                {
                    this.addToDataGridView(tempData [i]);
                }
                else
                {
                    if (tempData [i].index != -1) //an existing entry was updates
                    {
                        this.editDataGridView(tempData [i]);
                    }
                }
            }

            //!!!! ADD - the richTextBox display
        }
//
        private void addToDataGridView (teamDataItem tempEntry) //updates dataGridView1 by adding a new item (in thread safe)
        {
            if (this.dataGridView1.InvokeRequired) //if the calling thread is different then the one that created dataGridView1
            {
                SetDGV_New_Callback dgvCall = new SetDGV_New_Callback(addToDataGridView);
                this.Invoke(dgvCall, new object [] { tempEntry });
            }
            else //if the same thread that created dataGridView1
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows [dataGridView1.RowCount - 1].HeaderCell.Value = tempEntry.teamName;

                for (int i = 0; i < pointFields.Count; i++) //adds the point fields
                {
                    dataGridView1 [i, (dataGridView1.Rows.Count - 1)].Value = tempEntry.points [i];
                }
                for (int i = 0; i < flagNames.Count; i++) //adds the flag fields
                {
                    dataGridView1 [(pointFields.Count + i), (dataGridView1.Rows.Count - 1)].Value = tempEntry.flags [i]; //remember it must pass by the pointFields first
                }
            }
        }
//
        private void editDataGridView (teamDataItem tempEntry) //updates dataGridView1 by editing an existing line (in thread safe)
        {
            if (this.dataGridView1.InvokeRequired) //if the calling thread is different then the one that created dataGridView1
            {
                SetDGV_Edit_Callback dgvCall = new SetDGV_Edit_Callback(editDataGridView);
                this.Invoke(dgvCall, new object [] { tempEntry });
            }
            else //if the same thread that created dataGridView1
            {
                int indexFound = -1;
                for (int i = 0; i < dataGridView1.RowCount; i++) //looks for the index
                {
                    if (tempEntry.teamName == dataGridView1.Rows [i].HeaderCell.Value.ToString()) //found the same team
                    {
                        indexFound = i;
                        break;
                    }
                }

                if (indexFound != -1) //we found an entry
                {
                    for (int i = 0; i < pointFields.Count; i++) //adds the point fields
                    {
                        dataGridView1 [i, indexFound].Value = tempEntry.points [i];
                    }
                    for (int i = 0; i < flagNames.Count; i++) //adds the flag fields
                    {
                        dataGridView1 [(pointFields.Count + i), indexFound].Value = tempEntry.flags [i]; //remember it must pass by the pointFields first
                    }
                }

                //!!! No else in case a fluke happens and we need to add a new row instead (implement later)
            }
        }
//
    }
//
}

```

Now you'll see I have left commented code in there relating to my problem, at least where I think it lies. I have these threads that are used to parse the data, as well as add the data to the form. The initial thread that is calls in the `checkWebsite()` function, only calls that thread once, then there's a infinite while loop that has a timer (okay actually it's a subtract two DateTime values and if the time span is larger then x) that when executed reads in the webpage (using a cURl plugin).


I am going to assume that `readInThread.Abort();` line is okay for stopping that thread.


Anyway that's side tracked from the real problem, which is I have threads starting for the `updateForm()` and `updateForm_Data()` functions, but I never end them. Now when I watched the resource manager the CPU usage never went above 13% (please don't patronize me on that, I am new at this okay), but the memory usage I would watch go up and down, but was always progressively getting higher and higher.


I feel the automated garbage collector is the problem here and those classes in the functions I listed above are not being disposed off.


My question then is (and sorry it took me so long to get to this) how can I detect when these threads are done with their job and dispose them of their resources? They will be called again, as you can see it's reoccuring, but based on my knowledge of threads, I am create new threads everytime, which means all new resources.


I appreciate any help I can get, once again this is the first time I have worked with threads on this level, which I know can be a risky move. If you care to see some of my other classes, I can provide those (for instance the class that reads in the webpage using cURl). Or if maybe you see something else that's causing the problem I am listening. If I get this program to function properly, it could be a base model for when I build programs that use Threading in the future (there's already one I am waiting to build once I know this works).


Once again Thanks for any help
> 
> how can I detect when these threads are done with their job and dispose them of their resources?
> 
> 
> 


I think the `ThreadState` property will tell you want you need to know.
A couple of notes to get started:



> 
> .apply(literal\_eval)
> 
> 
> 


Wouldn't this be better as `map`?



> 
> I then re-create the Dask DF:
> 
> 
> ddf = dd.from\_pandas(ddf\_out, npartitions=nCores)
> 
> 
> 


`ddf_out` was already a dask dataframe, I don't know why you had to do this.



> 
> The columns in result seem to match those in metadir.
> 
> 
> 


The value of `result.columns` is taken from the meta you provided, no computing happens until you ask for it (dask is lazy in most operations). Does the ValueError exception not provide further information?


Here is a full example



```
x = ({'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'DEBRA MEALY',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'CHAIR PERSON',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'},
 {'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'HELEN GORDON',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'VICE CHAIR',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'})
df = pd.DataFrame({'a': x})
d = dd.from_pandas(df, 1)
meta = pd.DataFrame(columns=['F9_07_PZ_COMP_DIRECT', 
       'F9_07_PZ_DIRTRSTKEY_NAME',
       'F9_07_PZ_COMP_OTHER', 'F9_07_PZ_COMP_RELATED', 'F9_07_PZ_TITLE',
       'F9_07_PZ_AVE_HOURS_WEEK', 'F9_07_PC_TRUSTEE_INDIVIDUAL'], dtype="O")
d.map_partitions(lambda df: df.a.apply(pd.Series), meta=meta).compute()

```

How did I know what `meta` to use? I applied the function to the pandas dataframe - you might use a small piece of the dataframe to do this.


Some additional notes:


* it is an anti-pattern to load the data with pandas, pass to dask workers and then gather the whole result back to a pandas (in memory) dataframe, you are very unlikely to see a speedup this way and may incur a lot of overhead. You are better off loading with something like `dd.read_csv`, and aggregating or writing with dask functions too. Only `compute()` on something that will be small or not return anything (because it involves writing the output). The official examples do not use from\_pandas.
* string and dict processing are python methods, and so hold the interpreter lock (GIL) of any python function: threads will not actually run in parallel. To get parallelism, you need to run in processes, which is most easily achieved using <https://docs.dask.org/en/latest/setup/single-distributed.html>
* the distributed scheduler also gives you access to the dashboard, which has a lot of useful information to diagnose how your system is running. You can also configure a lot about its behaviour, in case you have firewall rules you need to obey. What is Delayed Branching ?
  

One way to maximize the use of the pipeline, is to find an instruction that can be safely exeucted whether the branch is taken or not, and execute that instruction. So, when a branch instruction is encountered, the hardware puts the instruction following the branch into the pipe and begins executing it, just as in predict-not-taken. However, unlike in predict-not-taken, we do not need to worry about whether the branch is taken or not, we do not need to clear the pipe because no matter whether the branch is taken or not, we know the instruction is safe to execute.
  

More Read : <https://www.cs.umd.edu/class/fall2001/cmsc411/projects/branches/delay.html>
  

Moving $I\_1$ after branch


* $I1$ is updating the value of  $R2$
* $R2$ which is used to determine branch condition $R1$
* Value of $R2$ is available after branch
  

$\Rightarrow$ `Cannot be moved`


Moving $I\_3$ after branch


* value of $R1$ is computed in this instruction
* $R1$ is the branch condition
  

$\Rightarrow$ `Cannot be moved`


Moving $I\_4$ after branch


* $I4$ is simple store instruction used to store R1 in memory
* program execution will have no effect if this is placed after conditional branch
  

$\Rightarrow$ `Can be moved`


Moving $I\_2$ after branch


* It update the memory location to place the storing of conditional branch instruction $R1$
* If moved after branch , when compiler reaches $I4$ program execution will stop
  

$\Rightarrow $ `Cannot be moved`


Hence, **option D is answer.** I suggest to use PostThreadMessage instead of SendMessage, check [PostThreadMessage Demystified](http://www.codeproject.com/Articles/225755/PostThreadMessage-Demystified)[[^](http://www.codeproject.com/Articles/225755/PostThreadMessage-Demystified "New Window")] for reasons. For Documentation see <http://msdn.microsoft.com/en-us/library/windows/desktop/ms644946%28v=vs.85%29.aspx>[[^](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644946%28v=vs.85%29.aspx "New Window")]  

  

And by the way if you want to invoke a function of your dialog class from your thread, then you need to send the "this"(present dialog object reference) as a parameter to the thread procedure. Are you sure you are doing this? Because in the code you are casting you lParam into an int which baffles me. When you call your threadproc you need to send "this" as "lParam".  

With SendMessage the code would look something like :   


```
 void ThreadProc(LPVOID lParam)
{
   CCurrentDialog* pDlg = (CCurrentDialog*)lParam;
   SendMessage(pDlg->m\_hWnd,ON\_CBN\_SELCHANGE,NULL,NULL);
}
```
  

  

You can use [PostMessage](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944%28v=vs.85%29.aspx)[[^](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944%28v=vs.85%29.aspx "New Window")] also. [image] dueck456:

is there an easy way to detect when new code is flashed to the device so i can reinitialize the retained variables?

below is a link to a post by [@rickkas7](/u/rickkas7) about storing retained data in a struct.

[image] dueck456:

saving a know value to eeprom jumps to mind

there is … hi,
thanks that does help tremendously! what you're dealing with is a "wait until ready" timeout condition. in other words test studio timed out waiting for the browser to say "i'm done downloading and rendering all the data for this website". there is a global setting for this which has a default value of just 30 seconds. it is the "client ready timeout" setting as shown in the [last figure on this page](http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/test-execution/quick-execution.aspx) for quick execution. an equivalent setting exists in [the test list settings](http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/test-execution/test-list-settings.aspx) when running your tests as part of a test list..  

  

if you don't want to set it globally (which can make sense to have the timeout much shorter for the remainder of your test) you'll have to resort to performing your navigate step in code... but it's pretty easy. try this:  

  


`int` `oldvalue = manager.settings.clientreadytimeout;`
`manager.settings.clientreadytimeout = 360000;`
`activebrowser.navigateto(``"my website here"``);`
`manager.settings.clientreadytimeout = oldvalue;`




kind regards,  

 cody   

the telerik team


do you want to have your say when we set our development plans?
do you want to know when a feature you care about is added or when a bug fixed?
explore the [telerik public issue tracking](http://www.telerik.com/support/pits.aspx)
system and vote to affect the priority of the items Magda, have you found what you need, yet?


I did this many years ago. It is simple… the 2nd time you do it!  

Exit points are simply “interrupts” that IBM supplies. You can attach programs to them, and the programs will automatically run at that point. For setting your AS/400 up to accept FTP logons, for example, the exit point is:  

QIBM\_QTMF\_SVR\_LOGON and the format you wil use is: TCPL0100.


A program inserted there can control WHO can log on, and when.  

To control WHAT they can do, you use another exit point, QIBM\_QTMF\_SERVER\_REQ and use format VLRQ0100.


My notes (from 1999) say I used the IBM TCP manual to get this info, specifically: TCP/IP manual SC41-5420-01 page I-14.


I do not know if it will allow me to post code here, it is long and complex due to the number of variables and some of them being in hex.


Write me (drow@waxie.com) if you would like me to email you my program code.


David Row  

WAXIE Sanitary Supply  

San Diego, CA





This is a link for [Add-ons for Firefox](https://addons.mozilla.org/en-US/firefox/). These are programs written by users or developers that the browser knows how and when to call. The developers of Firefox designed it to allow external programs to be hooked in by users of the browser.


IBM did something similar for a lot of the TCP/IP and other server functions. (And a lot of other things.) When you connect to the FTP server for example, the server checks to see if a program has been registered to process FTP logon requests. The registered program is an ‘exit program’.


Browser add-ons get an entry added to a file someplace within the browser directory structure. In your iSeries, the entry would be added to the Registration Facility. (Not always, but that’s the commonly recognized object for exit points and programs.) Use WRKREGINF to review your registration facility.


To create an exit program, you need to know the parameter list that will be passed to your program and the exit protocol. To find the parameter list, you should start looking at the documentation for the server the exit program will be associated with. The protocol, the meanings of the parms and what to with them, is also there.


A FTP exit program would be structured after documentation within the [File Transfer Protocol exit programs](http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzaiq/rzaiqreferenceexit.htm) topic of the Information Center for your release.


Once registered, a server logon exit program (for example) would be called just before the server decides whether or not to accept the logon. Your exit program directly influences that decision by returning an ‘accept or reject’ parameter. It chooses based on examination of the input parms.


The exit program may control who can and cannot logon, where they may logon from, what times of day logons are accepted, or it might accept all logons — its purpose can be simply to write all logons to a log file or to send a message when particular logons happen. Your exit program can do whatever it is programmed to do at that point in the logon process.


It doesn’t have to be a ‘security’ function. It’s whatever you want it to be.


For the FTP server, there are two general exit points. One is just before a logon is accepted. The other is just before each transaction in a session is processed. You can control individual transactions just as you can logons. (FTP client has its own exit points.)


Most other exit programs work on similar principles.


A few issues complicate things.


* An exit program needs enough authority to do whatever it needs to do; it can’t always rely on the authority of the session user.
* An exit program shouldn’t unduly delay transactions; there’s no way to know how often an exit program may be called, so you don’t want it slowing down every single transaction.
* Exit programs may be called by many instances of a server at the same time; it shouldn’t be locking things that are needed by a different instance.
* IBM changes the interfaces at times and the servers themselves can get PTFs; regular, on-going maintenance can be needed — keep the programs direct with little complication.
* There are other issues, but those are enough to consider.


Code a very simple exit program that accepts the parms and returns an ‘Accept’ indication. Don’t have it do anything except maybe send a message to a message queue. That lets you see how the registration facility works and how the parms work. It also gives you a program that you can register and deregister in the future to check whether or not the server is stilling calling your program correctly. (Problems can happen.)


Tom hi there floriann software,

first of all, i would say that it is always a better idea to open up a new thread, instead of engaging in an old one.

apart from that, as the drive is recognized on other systems except for the xp one, then it comes to drivers. make sure you go to the mobo's website and update the drivers.
is the drive initialized as mbr. in case it is initialized as gpt, i would advise you to back up all the data and initialize it as mbr. win xp has some limitations on that: https://support.microsoft.com/en-us/kb/2581408

cheers,
d\_know\_wd :) okay, i think i found out what is happening: <https://github.com/drtimothyaldendavis/suitesparse/issues/45> msom 301 exam #2 review guide chapters 9, 10, 11, 12, and 15  50 multiple choice questions worth one point each (plus an extra credit question worth one point)  review (don’t memorize) all powerpoint slides on blackboard and your notes  bring a #2 pencil and a blank scantron form, and valid gmu id.  i post your grade on blackboard; i do not return the test. please note – the number of questions given below for each chapter might not equal to  the number of topics since, in a few instances, there is more than one question on a topic. chapter 9 ­ 9 questions  managing diversity/providing opportunities o managing diversity and inclusion­ managing a culturally diverse  workforce by recognizing the characteristics common to specific group of  employees while dealing with such employees as individuals and  supporting, nurturing, and utilizing their differences to the organization’s  advantage o equal employment opportunity (eeo): “freedom from discrimination on the basis of sex, color, religion, national origin, disability, and age”  diversity management programs­ value and leverage diversity  of all stakeholders—from employees to customers—to achieve  competitive advantage  affirmative action­ special efforts to recruit and hire qualified  members of groups that have been discriminated against in the  past  hostile work environment occurs when unwelcome sexual conduct “has the  purpose or effect of unreasonably interfering with job performance or creating an  intimidating, hostile, or offensive working environment.” o i.e. persistent or pervasive displays of pornography, lewd or suggestive  remarks, and demeaning taunts or jokes  sexual harassment­ conduct of a sexual nature that has negative  consequences for employment  glass ceiling­ metaphor for an invisible barrier that makes it difficult to rise  above a certain level in the organization  employee support groups can provide emotional and career support for  members who traditionally haven’t been included in the majority’s informal group o i.e. apple has a jewish culture group, gay/lesbian group, african­ american group, and technical women’s group  anticipated labor force  o by 2050:  the percent of whites in the labor force will decrease to about  48.2%  1/3 of workers will be of hispanic origin  hispanics are the largest and fastest­growing minority  percentage of black workers will slightly increase to 12.4% 1 
  asians will make up 8.6% of all civilian workers o  phased retirement­ allow older employees to work fewer hours per week o retirees return to work because employers don’t want to lose their  accumulated knowledge, willingness to work nontraditional shifts, and  their reliable work habits chapter 10 ­ 10 questions   strategic leadership is a behavior that gives purpose and meaning to  organizations, envisioning and creating a positive future  sources of power o legitimate power­ leader has the right or authority to tell people what to  do; employees are obliged to comply with legitimate order o reward power­ leader influences others because s/he controls valued  rewards; employees comply to receive those rewards o coercive power­ leader has control over punishments; employees comply to avoid punishments o referent power­ leader has personal characteristics that appeal to others; employees comply because they like the leader, desire for approval, or  want to be that leader o expert power­ leader has certain expertise or knowledge; employees  comply because they believe in, can learn from, or otherwise gain from  that expertise  traits of effective leaders o drive­ set of characteristics that reflect a high level of effort, including high need for achievement, constant striving for improvement, ambition,  energy, tenacity (persistence in the face of obstacles), and initiative o leadership motivation  extraversion is consistently related to leadership emergence and  leadership effectiveness o integrity­ correspondence between actions and words o self­confidence­ ability to overcome obstacles, makes decisions despite  uncertainty, and instills confidence in others o knowledge of the business: leaders should have a high level of  knowledge about their industries, companies, and technical matters  leaders should also have intelligence to interpret vast quantities of information  behavioral approach­ leadership perspective that attempts to identify what  good leaders do­­ that is, what behaviors they exhibit 2 
  decision styles o autocratic­ leader makes decisions on his/her own and then announces  those decisions to the group  results in higher performance than democratic style o democratic­ leader solicits input from subordinates  results in the most positive attitudes o laissez­faire­ leader essentially makes no decisions o situational approach­ leadership perspective proposing that universally  important traits and behaviors do not exist, and that effective leadership  behavior varies from situation to situation  participation in decision­making o autocratic leadership­ leader makes decisions on his/her own and then  announces those decisions to the group o democratic leadership­ leader solicits input from subordinates o laissez­faire­ leadership philosophy characterized by an absence of  managerial decision making  university of michigan studies concluded that task­oriented behavior and  relationship­oriented behavior should be exhibited in order to be an effective  manager  situational approach­ leadership perspective proposing that universally  important traits and behaviors do not exist, and that effective leadership behavior varies from situation to situation  vroom model­ situational model that focuses on the participative dimension of  leadership o factors used to analyze problems  decision significance  importance of commitment  leader’s expertise  likelihood of commitment  group support for objectives  group expertise  team competence  fiedler’s contingency model of leadership effectiveness postulated that  effectiveness depends on the personal style of the leader and the degree to  which the situation gives the leader power, control, and influence over the  situation chapter 11 ­ 13 questions  four consequences of behavior o positive reinforcement­ applying a consequence that increases the  likelihood that the person will repeat the behavior that led to it o negative reinforcement­ removing or withholding an unpleasant  consequence o punishment­ administer an aversive consequence o extinction­ withdrawing or failing to provide a reinforcing consequence.  when this occurs, motivation is reduced, and the behavior is  extinguished, or eliminated  expectancy theory­ theory proposes that people will behave based on their  perceived likelihood that their effort will lead to a certain outcome and on how  highly they value that outcome 3 
 o  abraham maslow’s need hierarchy­ human needs theory postulating that  people are motivated to satisfy unmet needs in a specific order o  erg theory postulates that people have three basic sets of needs that can  operate simultaneously o existence needs­ all materials and physiological desires o relatedness needs­ relationships with other people and are satisfied  through the process of mutually sharing thoughts and feelings o growth needs­ motivate people to productively or creatively change  themselves or their environment  extrinsic and intrinsic rewards o extrinsic reward­ reward given to a person by the boss, the company, or some other person (i.e. praise, paycheck, bonuses) o intrinsic reward­ reward a worker derives directly from performing the  job itself (i.e. sense of accomplishment)  job enlargement­ giving people additional tasks at the same time to alleviate  boredom  job enrichment­ changing a task to make it inherently more rewarding,  motivating, and satisfying o hackman and oldham model of job enrichment 4 
   skill variety­ different job activities involving several skills and  talents  task identity­ completion of a whole, identifiable piece of work  task significance­ important, positive impact on the lives of others  meaning, responsibility and feedback provide motivation  autonomy­ independence and discretion in making decisions  feedback­ information about job performance  growth need strength­ degree to which individuals want  personal and psychological development  herzberg’s two­factor theory describes two factors that affect people’s work  motivation and satisfaction o hygiene factors­ workplace characteristics (i.e. policies, working  conditions, pay, supervision) that could make employees dissatisfied o motivators­ nature of the work itself, actual job responsibilities,  opportunity for personal growth and recognition, and the feelings of  achievement the job provides  empowerment­ process of sharing power with employees, thereby enhancing  their confidence in their ability to perform their jobs and their belief that they are  influential contributors to the organization  procedural justice­ using a fair process in decision making and making sure  others know that the process was as fair as possible chapter 12 ­ 11 questions  group and team definitions o group­ collection of people who interact to undertake a task but do not  necessarily perform as a unit or achieve significant performance  improvements o team­ small number of people with complementary skills who are  committed to a common purpose, set of performance goals, and  approach for which they hold themselves mutually accountable  traditional environment vs new team environment o traditional work groups were closely supervised 5 
 o today’s teams have more authority and often are self­managed o teams are now used in many more ways than in the past   look at exhibit 12.1 in the textbook  types of teams o work teams­ teams that make or do things, such as manufacture, sell,  assemble, or provide service o project and development teams­ teams that work on long­term projects  but disband once the work is completed o parallel teams­ teams that operate separately from regular work  structure and exist temporarily o management teams­ teams that coordinate and give direction to the  subunits under their jurisdiction and integrate work among subunits o transnational teams­ work groups composed of multinational members  whose activities span multiple countries o virtual teams­ teams that are physically dispersed and communicate  electronically more than face­to­face  stages of team development o  team leader roles o task specialist­ individual who has more advanced job­related skills and abilities than other group members possess o team maintenance specialist­ individual who develops and maintains  team harmony  groupthink occurs when a tightly knit group is very cooperative that agreeing  with one another’s opinions and refraining from criticizing others’ ideas become  norms  social loafing­ working less hard and being less productive when in a group  conflict management strategies o avoidance­ ignoring the problem by doing nothing at all, or  deemphasizing the disagreement o accommodation­ style of dealing with conflict involving cooperation on  behalf of the other party but not being assertive about one’s own interests 6 
 o compromise­ style of dealing with conflict involving moderate attention  to both parties’ concerns o competing­ style of dealing with conflict involving strong focus on one’s  own goals and little or no concern for the other person’s goals o collaboration­ style of dealing with conflict emphasizing both  cooperation and assertiveness to maximize both parties’ satisfaction chapter 15 ­ 8 questions  world­class organization o requires applying the best and latest knowledge and ideas and having  the ability to operate at the highest standards of any place anywhere o world­class companies create high­value products and earn superior  profits over the long run.  o they implement more effective and competitive organizational strategies,  structures, processes, and management of human resources o the result is an organization capable of competing successfully on a  global basis  chief information officer responsibilities include: o coordinating the technological efforts of the business units,  o representing technology in the top management team, o identifying ways that technology can support the company’s strategy, o supervising new technology development, o assessing the technological implications of major strategic initiatives such as acquisitions, new ventures, and strategic alliances o managing organization’s information technology (it) group   “tyranny of the or”­ belief that things must be either a or b and cannot be both o “genius of the and”­ ability to achieve multiple objectives at the same time  organizational development (od)­ systemwide application of behavioral  science knowledge to develop, improve, and reinforce the strategies, structures,  and processes that lead to organizational effectiveness o  human resources management o od intervention: attracting good people, setting goals, and appraising and rewarding performance  reasons for resisting change o inertia o timing o surprise 7 
 o peer pressure o self­interest o misunderstanding o different assessments o management tactics  force­field analysis­ approach to implementing lewin’s  unfreezing/moving/refreezing model by involving identifying the forces that  prevent people from changing and those that will drive people toward change o unfreezing­ realize that current practices are inappropriate and that new  behavior is necessary o moving­ instituting the change o refreezing­ strengthening the new behaviors that support the change  proactive change­ anticipating and preparing for an uncertain future; implies  being a leader and creating the future you want 8 there is no need for a program to do that. 

here are some simple steps which you can follow:

1.right click on your taskbar and choose start task manager.

2.once task manager is opened go to "processes" tab. 

3.when at the processes tab search for .exe file. (maybe in your case it will look like loop.exe or something) 

4.once you have found it. just right-click on it and hover over to "set priority" option. 

5.here are several options. the default one will be "normal" so just set that to "below normal" or "low". (i would prefer setting it to "below normal" so that it does not act strangely) 

6.it's done now restart your program and check the amount of ram it is using.

i hope this helps you. if not leave a reply and i will figure out another solution. glad to help.:)