Skip to content

Commit daebbf8

Browse files
author
greatabel
committed
old code
0 parents  commit daebbf8

430 files changed

Lines changed: 5381 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

8 KB
Binary file not shown.

DeadLock_CH3/DeadLock_CH3.csproj

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{D1440C2F-664F-4922-B3F9-AE76475B74C4}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>DeadLock_CH3</RootNamespace>
12+
<AssemblyName>DeadLock_CH3</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
<FileAlignment>512</FileAlignment>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18+
<PlatformTarget>x86</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28+
<PlatformTarget>x86</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
50+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
51+
Other similar extension points exist, see Microsoft.Common.targets.
52+
<Target Name="BeforeBuild">
53+
</Target>
54+
<Target Name="AfterBuild">
55+
</Target>
56+
-->
57+
</Project>

DeadLock_CH3/Program.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Threading;
3+
namespace DeadLock_CH3
4+
{
5+
class DL
6+
{
7+
int field_1 = 0;
8+
private object lock_1 = new int[1];
9+
10+
int field_2 = 0;
11+
private object lock_2 = new int[1];
12+
13+
public void First(int val)
14+
{
15+
lock (lock_1)
16+
{
17+
Console.WriteLine("First :acquired lock_1:" + Thread.CurrentThread.GetHashCode() + " Now sleeping");
18+
Thread.Sleep(1000);
19+
Console.WriteLine("First :wanting lock_2");
20+
lock (lock_2)
21+
{
22+
Console.WriteLine("First :acquired lock_2:" + Thread.CurrentThread.GetHashCode() + " Now sleeping");
23+
field_1 = val;
24+
field_2 = val;
25+
}
26+
}
27+
28+
}
29+
public void Second(int val)
30+
{
31+
lock (lock_2)
32+
{
33+
Console.WriteLine("First :acquired lock_2:" + Thread.CurrentThread.GetHashCode() + " Now sleeping");
34+
Thread.Sleep(1000);
35+
Console.WriteLine("First :wanting lock_1");
36+
lock (lock_1)
37+
{
38+
Console.WriteLine("First :acquired lock_1:" + Thread.CurrentThread.GetHashCode() + " Now sleeping");
39+
field_1 = val;
40+
field_2 = val;
41+
}
42+
}
43+
}
44+
45+
}
46+
class MainApp
47+
{
48+
DL d = new DL();
49+
static void Main(string[] args)
50+
{
51+
MainApp m = new MainApp();
52+
Thread t1 = new Thread(new ThreadStart(m.Run1));
53+
t1.Start();
54+
Thread t2 = new Thread(new ThreadStart(m.Run2));
55+
t2.Start();
56+
57+
}
58+
public void Run1()
59+
{
60+
this.d.First(10);
61+
62+
63+
}
64+
public void Run2()
65+
{
66+
this.d.Second(10);
67+
}
68+
}
69+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("DeadLock_CH3")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("DeadLock_CH3")]
13+
[assembly: AssemblyCopyright("Copyright © 2012")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("56535f3d-e4e0-4399-bd08-f62be135b1b0")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
6 KB
Binary file not shown.
13.5 KB
Binary file not shown.
11.3 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
8+
</requestedPrivileges>
9+
</security>
10+
</trustInfo>
11+
</assembly>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
C:\Users\abel\Documents\Visual Studio 2010\Projects\ThreadLearn\DeadLock_CH3\bin\Debug\DeadLock_CH3.exe
2+
C:\Users\abel\Documents\Visual Studio 2010\Projects\ThreadLearn\DeadLock_CH3\bin\Debug\DeadLock_CH3.pdb
3+
C:\Users\abel\Documents\Visual Studio 2010\Projects\ThreadLearn\DeadLock_CH3\obj\x86\Debug\ResolveAssemblyReference.cache
4+
C:\Users\abel\Documents\Visual Studio 2010\Projects\ThreadLearn\DeadLock_CH3\obj\x86\Debug\DeadLock_CH3.exe
5+
C:\Users\abel\Documents\Visual Studio 2010\Projects\ThreadLearn\DeadLock_CH3\obj\x86\Debug\DeadLock_CH3.pdb
6 KB
Binary file not shown.

0 commit comments

Comments
 (0)